I have an Html page with an scroll ,and I'd like when the page starts (onload) to put the focus in the 60% parox (y axis) of the page. that means to scroll automatically the 60% of the page.
is this possible? thankyou
I have an Html page with an scroll ,and I'd like when the page starts (onload) to put the focus in the 60% parox (y axis) of the page. that means to scroll automatically the 60% of the page.
is this possible? thankyou
You can use window.scrollBy() method:
http://www.mediacollege.com/internet/javascript/page/scroll.html
Or use scrollTo jQuery plugin, which gives you more flexibility.
function pageScroll() {
var height = document.documentElement.clientHeight;
window.scrollBy(0, Math.floor(0.6 * height)); // horizontal and vertical scroll increments
}
window.onload = pageScroll;
<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>
Depending on what you want to display, you can add id selectors to you content and then have the page skip to them using a url eg.
<div id="content">
<!--Content Goes Here -->
</div>
And open the page using:
http://www.mysite.com/mysite.html#content
Another example would be this:
http://stackoverflow.com/questions/2872688/start-html-page-scrolled#answer-2872722