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
- var _run;
- if(navigator.userAgent.indexOf("Firebird")!=-1||navigator.appName=="Microsoft Internet Explorer")
- {_run=false;}
- else {_run= true;}
- function vScroll()
- {
- var top = (window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;
- parent.frames["right"].scrollTo(0,top);
- }
- function searchScroll(){
- var top = (window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;
- parent.frames["right"].scrollTo(0,top);
- window.setTimeout("searchScroll();",1);
- }
- if(_run == false)
- {
- window.onscroll=function(){vScroll();}
- } else {
- window.onload=function(){searchScroll()}
- }
If there a way around this or a better solution??
Cheers
Tom