Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script works with IE, but not with FF

Status
Not open for further replies.

JohnnyBeta

Technical User
Dec 4, 2007
3
CA
I have a menu which stays in the middle of the screen when the page is scrolled down or up,
which is what I want.

It works with IE 6 or 7, but not with Moz or FF2.

Why does it not work with FF ?

Here's the script:

function setVariables() {
if (navigator.appName == "Netscape") {
v=".top=";
dS="document.";
sD="";
y="window.pageYOffset";
}
else {
v=".pixelTop=";
dS="";
sD=".style";
y="document.body.scrollTop";
}
}
function checkLocation() {
object="object1";
yy=eval(y);
eval(dS+object+sD+v+yy);
setTimeout("checkLocation()",10);
}

Thanks for any help.
 
I'll tell you why it doesn't work in FF if you can tell me why it DOES work in IE.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
It probably doesn't work because that code looks like something out of the dark ages with all that old-hat browser detection from the late 1990s (well before FF was released).

Re-writing it to use modern DOM methods would be a far better bet.

If you need further help, perhaps posting the menu code in question would be helpful?

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I had a feeling it was an oldie.
I'm not a programmer, you see. HTML and CSS is as far as my competence goes.

As for the menu code, what I posted is pretty much it.

There's some CSS bits, and an event handler like
onclick="loadStyleSheets(4,0)"
but no more.

I checked QuirksMode (which is waaaaay over my head anyways), and my very wild guess is that my script doesn't recognize FF2, or any FF's for that matter.

It also does not work with some older versions of Moz.

 
Instead of us breaking down the script for you to get it more cross browser compatible, it would probably be in your best interest to just go find a different script that suits your needs. Dan is correct, that script is a fossil. And when you're looking for a new cross-browser compatible script, a good rule of thumb is to not use anything that has a line in it like this:
Code:
if (navigator.appName == "Netscape") {
Browser sniffing is very clunky and unreliable.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top