Start scrolling html page

I have an Html page with a scroll and I would like the start page (onload) to put focus on 60% of the parox (y-axis) of the page. this means auto scrolling 60% of the page.

Is it possible? Thankyou

+2


a source to share


6 answers


Try this site: link text



It should work!

+2


a source


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

window.onload = pageScroll;

      



+1


a source


With jQuery and scrollTop

:

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

      

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

0


a source


You can use window.scrollBy () method:

http://www.mediacollege.com/internet/javascript/page/scroll.html

Or use the jQuery scrollTo plugin which gives you more flexibility.

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

0


a source


<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>

      

0


a source


Depending on what you want to display, you can add id selectors to your content and then skip the page using a url for example.

<div id="content">
  <!--Content Goes Here -->
</div>

      

And open the page using:

http://www.mysite.com/mysite.html#content

Another example would be the following:

scroll html page

0


a source







All Articles