views:

60

answers:

6

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

A: 

With jQuery and it's scrollTop method:

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

Then it scrolls to 0.6 times the document's height when the page has finished loading. :)

sirhc
A: 

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.

http://plugins.jquery.com/project/ScrollTo

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

window.onload = pageScroll;
karim79
+3  A: 

Try this website: link text

Thats should work!

Ryano
ARGHHHHHHHHHH STOP IT FROM SCROLLING!! :O!
Neurofluxation
A: 
<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>
Dirk Einecke
A: 

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

James