加入js代码
<style type="text/css"> body { height: 2000px; } </style> <script type="text/javascript"> onload = function () { var dh = document.documentElement.scrollHeight || document.body.scrollHeight; window.scrollTo (0, (dh - screen.availHeight) / 2); } </script>
配合判断是否是手机端使用代码
<script type="text/javascript"> <!-- //平台、设备和操作系统 var system ={ win : false, mac : false, xll : false }; //检测平台 var p = navigator.platform; system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); //跳转语句 if(system.win||system.mac||system.xll){ onload = function () { window.scrollTo (0,495); } }else{ //如若手机则跳转的页面路径 } --> </script>