469,346 Members | 6,483 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,346 developers. It's quick & easy.

Scroll 2 windows at once in IE7

7
Hi Guys,

I'm writing a little webbased application for my bosses at work which utilises PHP, Javascript and HTML.
I have very little knowledge of javascript itself but I found a script that allowed 2 seperate frames on 1 page to be scrolled at the same time, which I needed as I am showing table row headers in 1 small side column and the rest of the table in the main window but as its taller than the page they need to scroll at the same time.

On me loading my frameset the script works fine and both windows scroll together exactly how I would like, I then tell it to load my table into the main frame window and then load the row headers in to the side column and it no longer scrolls together which is an issue to say the least. I have included the code on the page I am opening and in Firefox and Konqueror the script works as I would like when I click on the link.

The script is as follows:
Expand|Select|Wrap|Line Numbers
  1. var _run;
  2. if(navigator.userAgent.indexOf("Firebird")!=-1||navigator.appName=="Microsoft Internet Explorer")
  3. {_run=false;}
  4. else {_run= true;}
  5.  
  6. function vScroll()
  7. {
  8. var top = (window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop; 
  9.  
  10. parent.frames["right"].scrollTo(0,top);
  11.  
  12. }
  13.  
  14. function searchScroll(){
  15. var top = (window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;
  16.  
  17. parent.frames["right"].scrollTo(0,top);
  18.  
  19. window.setTimeout("searchScroll();",1);
  20.  
  21. }
  22. if(_run == false)
  23. {
  24. window.onscroll=function(){vScroll();} 
  25. } else { 
  26. window.onload=function(){searchScroll()}
  27. }
  28.  
You put this at the top of the page you would like to be in control of the scrolling the the rest works like magic, just not when you start reopening pages in IE.

If there a way around this or a better solution??

Cheers

Tom
May 11 '07 #1
1 2265
iam_clint
1,208 Expert 1GB
what do you mean by reopening? refreshing the page?
May 11 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.