Pages

About

Powered by Blogger.

Followers

12 August 2013

How to Add auto page scroll to particular location

by Unknown  |  in TIPS at  8/12/2013

    
  In some site development process we require auto scrolling of page to the particular point of the web page on button click.   We can do this by using simple javascript. we can define the jumping point by write the pixel position in horizontal and vertical.

* Paste below code ] in head section.

<script type="text/javascript">
    function jumpScrollup() {
       window.scroll(0,0); // horizontal and vertical scroll targets
}
function jumpScroll() {
       window.scroll(0,800); // horizontal and vertical scroll targets
}
</script>


here (0,800) shows the pixel position that you want to jump. 0 for horizontal and 800 for vertical pixel position. you can change this pixel positions.

* Add below code to where you want to add the jumping function such as button click or links.

<a href="javascript:jumpScroll()">Link name</a>

you can use these codes to many times in a single page by changing the pixel positon.

0 comments:

Proudly Powered by Blogger.