David Simon David Simon - 2 years ago 205
Javascript Question

Scroll to top after history.back

Sorry, but my english is very bad.

How can I do to scroll to top in a php-site after use history.back?

Example: The page1.php is active. I use history.back to come back
to page0.php. page0.php is not loading again, but i will scroll
to top with jquery.

How can I do that?

Bye, David

Answer Source

Use below script in that page, in which you want to go to top of page.

<script type="text/javascript">
    $(window).bind("pageshow", function() {
        $("html, body").animate({
           scrollTop: 0
        }, 600);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download