开发者

Sync scrolling of two frames (browser-agnostic, please!)

开发者 https://www.devze.com 2023-01-03 15:42 出处:网络
I have a web page made of three frames, something like this: +----------------+ |0| +-------+--------+

I have a web page made of three frames, something like this:

+----------------+
|       0        |
+-------+--------+
|       |        |
|   1   |    2   |
|       |        |
+-------+--------+

Frames 1 and 2 are for comparing s开发者_如何学Goome similar data. I'd like to sync the vertical scrollbars on these frames (setting the scroll bar value on both sides to be the same).

My current approach is to have the following code in frame 0:

<script>
   function scroll_sync() {
      var f1 = window.parent.frames[1];
      var f2 = window.parent.frames[2];

      f1.onscroll = function () { f2.scroll(f2.scrollX, f1.scrollY); }
      f2.onscroll = function () { f1.scroll(f1.scrollX, f2.scrollY); }
   }

  dojo.addOnLoad(scroll_sync);
</script>

This works fine in Firefox 3.x and Chrome 5.x. Not in Internet Explorer 8, though. Any ideas?


In IE I think you need to use scrollTo like: f2.scrollTo(0,f1_scroll_position);

0

精彩评论

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

关注公众号