Why wont JS script trigger on mouse-over in NS and Mozilla

  • Thread starter news frontiernet.net
  • Start date
N

news frontiernet.net

I have a project that uses mouse-over JS script to show and hide layers that
works well in MSIE 6.0 and Opera.

But, it does not work in NS nor Mozilla.

It is here: http://www.wgtn.net/Business/category_layer.htm

A mouse-over of any of the letters in that left vertical panel of letters
shoud trigger a JS script that shows the appropriate panel on the right.

The code pases HTML and CSS validation.

What could be inhibiting the mouse-over trigger in NS and Mozilla?
 
D

David Dorward

news said:
I have a project that uses mouse-over JS script to show and hide layers
that works well in MSIE 6.0 and Opera.

But, it does not work in NS nor Mozilla.

It is here: http://www.wgtn.net/Business/category_layer.htm

It is being triggered. You test for document.all, which is a non-standard
DOM supported by IE and Opera, then you test for document.layers, which is
a non-standard DOM supported by Netscape 4.x. Then you give up.

Try using the standard:
http://w3.org/TR/1998/REC-DOM-Level-1-19981001/

(Note that you'll want to use the ECMA Script Language Binding to DOM 1 for
this)
 
D

Dag Sunde

news frontiernet.net said:
I have a project that uses mouse-over JS script to show and hide layers that
works well in MSIE 6.0 and Opera.

But, it does not work in NS nor Mozilla.

It is here: http://www.wgtn.net/Business/category_layer.htm

A mouse-over of any of the letters in that left vertical panel of letters
shoud trigger a JS script that shows the appropriate panel on the right.

The code pases HTML and CSS validation.

What could be inhibiting the mouse-over trigger in NS and Mozilla?

Skip this:

if (document.layers && document.layers[object]) {
document.layers[object].visibility = 'visible';
}
else if (document.all) {
document.all[object].style.visibility = 'visible';
}

and replace it with this:
if( document.getElementById )
document.getElementById(object).style.visibility = 'visible';
else
alert("Please download a decent Standard compliant browser!");


What you do is some half-hearted IE/Opera and NS4 testing (Both
non-standard).
document.getElementById(...) is supported by all the browsers worth worrying
about. (NS 4.x is NOT one of them!)
 
N

news frontiernet.net

Thanks!

That does make the trigger work for NS too.

However there seems to still be an oddity. While the trigger works going
DOWN the panel of letters, settin each corresponding layer to visible and
displaying the correct material for that letter. It doesnt work in NS going
back UP the panel of letters. It works in MSIE.

Are there other browser specific errors with this JS script that are causing
this?



Dag Sunde said:
news frontiernet.net said:
I have a project that uses mouse-over JS script to show and hide layers that
works well in MSIE 6.0 and Opera.

But, it does not work in NS nor Mozilla.

It is here: http://www.wgtn.net/Business/category_layer.htm

A mouse-over of any of the letters in that left vertical panel of letters
shoud trigger a JS script that shows the appropriate panel on the right.

The code pases HTML and CSS validation.

What could be inhibiting the mouse-over trigger in NS and Mozilla?

Skip this:

if (document.layers && document.layers[object]) {
document.layers[object].visibility = 'visible';
}
else if (document.all) {
document.all[object].style.visibility = 'visible';
}

and replace it with this:
if( document.getElementById )
document.getElementById(object).style.visibility = 'visible';
else
alert("Please download a decent Standard compliant browser!");


What you do is some half-hearted IE/Opera and NS4 testing (Both
non-standard).
document.getElementById(...) is supported by all the browsers worth worrying
about. (NS 4.x is NOT one of them!)
 
L

Lee

news frontiernet.net said:
Thanks!

That does make the trigger work for NS too.

However there seems to still be an oddity. While the trigger works going
DOWN the panel of letters, settin each corresponding layer to visible and
displaying the correct material for that letter. It doesnt work in NS going
back UP the panel of letters. It works in MSIE.

Are there other browser specific errors with this JS script that are causing
this?

You need to fix your "hide()" function, too.
Currently, it's never hiding any layer, so once a layer has been
made visible, there's no way to see any "lower" layer.
 
N

news frontiernet.net

Yes !!!

That works!

I am a cut-n-paste js script user. That script has been around a while.

Thank you!
 
L

Lasse Reichstein Nielsen

news frontiernet.net said:
I am a cut-n-paste js script user. That script has been around a while.

And it shows!
That script was probably created four or five years ago, back when the only
browsers being recognized was IE 4 and Netscape 4. Luckily, we are long
past that, but some scripts fail to retire gracefully :)
/L
 
T

Thomas 'PointedEars' Lahn

David said:
news said:
I have a project that uses mouse-over JS script to show and hide layers
that works well in MSIE 6.0 and Opera.

But, it does not work in NS nor Mozilla.
[...]

[...]
Try using the standard:
http://w3.org/TR/1998/REC-DOM-Level-1-19981001/

You are a bit behind time.
(Note that you'll want to use the ECMA Script Language Binding to DOM 1
for this)

No, he does not want that, for there is no _ECMAScript_ Language Binding
for (Cascading) Style Sheets in DOM Level 1, in contrast to DOM Level 2:

<http://www.w3.org/TR/DOM-Level-2/>
<http://www.w3.org/TR/DOM-Level-2-HTML/>
<http://www.w3.org/TR/DOM-Level-2-Style/>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top