开发者

Scrollbar position problem on location.reload()

开发者 https://www.devze.com 2023-01-25 22:44 出处:网络
<div style=\'height:2000px;\'>please scroll down</div> <a href=# onclick=\"location.reload();return false;\">Reload Page</a>
<div style='height:2000px;'>please scroll down</div>
<a href=# onclick="location.reload();return false;">Reload Page</a>
<div style='hei开发者_运维技巧ght:1000px;'>...</div>

demo here

in chrome or firefox,when I click "Reload Page",the page can revert to my scrolltop,

but in IE(6,7,8),they stay on the top

how to implement revert scrolltop effect like chrome in IE?

thanks for help :)


Use scroll function, here's an example:

  • http://www.java2s.com/Code/JavaScript/Javascript-Objects/WindowscrollExample.htm

Here's an example of <a> similar to what you want:

<a href="javascript:scroll(0,0)">
Top
</a>

You can combine both if you actually want to scroll and reload.

0

精彩评论

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