单击按钮时如何保持滚动位置。 [英] How to hold the position of scroll when button is clicked.

查看:60
本文介绍了单击按钮时如何保持滚动位置。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它似乎适用于谷歌Chrome,但不适用于IE7。为什么?



有谁能告诉我为什么?我搜索网仍然没有答案。非常感谢你提前:)



ON HEADER:

It seems working on Google Chrome but not in IE7. Why is it?

Can anyone please tell me why? I've search the net still has no answer . Thank you so much in advance :)

ON HEADER:

<script type="text/javascript">
        window.onload = function () {
            var div = document.getElementById("divscroll");
            var div_position = document.getElementById("div_position");
            var position = parseInt('<%=Request.Form("div_position") %>');
   if (isNaN(position)) {
       position = 0;
   }
   div.scrollTop = position;
   div.onscroll = function () {
       div_position.value = div.scrollTop;
   };
};
</script>





ON BODY:



ON BODY:

<div class="scroll" id="divscroll">
                <input type="hidden" id="div_position" name="div_position" />

推荐答案

IE在窗口方面存在一些问题.load函数你可以试试



IE has some problems with window.load function you can try

For IE try:

window.onload = new function() { alert('hello');};





阅读以下链接:



http ://stackoverflow.com/questions/886668/window-onload-is-not-firing-with-ie-8-in-first-shot [ ^ ]





http://stackoverflow.com/questions/12610951/getting-not-implemented-for-window-onload-in-ie-javascript-debugger [ ^ ]





http:// stackoverflow .com / questions / 11906914 / window-onload-in-ie7 [ ^ ]



Read following links:

http://stackoverflow.com/questions/886668/window-onload-is-not-firing-with-ie-8-in-first-shot[^]


http://stackoverflow.com/questions/12610951/getting-not-implemented-for-window-onload-in-ie-javascript-debugger[^]


http://stackoverflow.com/questions/11906914/window-onload-in-ie7[^]


这篇关于单击按钮时如何保持滚动位置。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆