开发者

scroll top java script function?

In html, Generally people use scrolling to top of page like:

<a href="#top" title="Scroll back to the top">Back to the top</a>

But i need the web page go to top after clicking the link. file of left.php:

<div class"ida0">
   <a href="news.php" target="right_frame"  onclick="scrollToTop()">Link 1</a>
</div>

Because my web page is like this. * main.php * left.php * right.php

|----------------------------|

|----------------------------|

||some image || contents|

||---------------- || of link ||

||---------------- || --------||

||---------------- || --------||

||---------------- || --------||

||-----link1------ || --------||

||-----link2------ || --------||

||---------------- || --------||

||---------------- || --------||

I used this But didn't work.

<script language="javascript">
 开发者_StackOverflow   function scrollToTop()
    {
   document.getElementById(ida0).scrollTop = 0; //It scrolls to top
    }
</script>


function scrollToTop() {
    window.scroll(0, 0);
}


If you want to jump instantly to the top, you can use window.scrollTo(0, 0), or if you would like to animate the scroll, you can use something like jQuery.smoothScroll.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜