PDA

View Full Version : need a hand updating someone else's .JS to work with Gecko(NS6)


Beau
01-07-2003, 10:32 PM
I've been charged with updating an older DHTML menu system to work with Mozilla.

Assuming I've declared:
ns6=document.getElementById ? 1 : 0
ie=document.all?1:0
n=document.layers?1:0

How would I alter this existing line to work with Mozilla?
this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')

As-is, Mozilla rightfully skips the Netscape evaluation and hits the IE eval, resulting in "document.all is not an object" which I understand.

I initially thought that changing it to the following might take care of the problem, but Mozilla apparently skips right over the Netscape evaluations again, resulting in the same error.
this.css=(n||ns6) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')

I've tried turning it into a long if/else statement, reversing the logic to look for IE first and a number of other things that basically amount to me swinging blindly in the dark.

So far, nothing I've tried has made the menu appear in Mozilla, but I have managed to break it in IE a few times, usually getting the error "this.css is undefined".

There's more to the menu code obviously, but I reckon if I can get some help with this little spot, it'll make more sense and I can figure the rest out on my own.

Barring any ideas, can anyone recommend a good, cross-browser, -horizontal- menu system?

jkd
01-07-2003, 10:45 PM
this.css = n ? eval(nest+'document.'+obj) : document.getElementById(obj).style;

Beau
01-07-2003, 10:52 PM
By Jove, I think that did it!

Have I mentioned how much I <3 you guys? ;)

Thanks JKD!