2010-05-20 80 views
2

我有一个滚动的Html页面,我想当页面开始(onload)把焦点放在页面的60%parox(y轴)。这意味着自动滚动页面的60%。开始html页滚动

这是可能的吗?三江源

回答

0

随着jQuery和它的scrollTop方法:

function loadedScroll() { 
    $(window).scrollTop(0.6*$(document).height()); 
} 
window.onload = loadedScroll; 

然后滚动到当页面加载完成后0.6倍文档的高度。 :)

1
function pageScroll() { 
    var height = document.documentElement.clientHeight; 
    window.scrollBy(0, Math.floor(0.6 * height)); // horizontal and vertical scroll increments 
} 

window.onload = pageScroll; 
2

试试这个网站: link text

那应该工作!

+1

ARGHHHHHHHHHH STOP从SCROLLING! :噢! – 2010-05-20 10:20:31

0
<html> 
    <head> 
     <script> 
      scroller = function() { 
       bodyHeight = Math.max(
        Math.max(document.body.scrollHeight, document.documentElement.scrollHeight), 
        Math.max(document.body.offsetHeight, document.documentElement.offsetHeight), 
        Math.max(document.body.clientHeight, document.documentElement.clientHeight) 
       ); 
       scrollToPosition = Math.floor(bodyHeight/100 * 60); 
       window.scrollTo(0, scrollToPosition); 
      } 
     </script> 
    </head> 
    <body onload="scroller()"> 
    </body> 
</html>