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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More freakin' Netscape problems. I

Status
Not open for further replies.

MajorTechie

Programmer
Mar 20, 2002
30
CA
More freakin' Netscape problems. I have an expandable/collapsable menu script using DHTML. I've simplified it here just to give a snippit. Point being, Netscape doesn't like it and gives me the following errors:

ACPower is not defined.
window.ACPower has no properties.


Here's the code:


<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function ACPowerOpen() {
window.ACPower.style.display = &quot;list-item&quot;;
}

function ACPowerClose() {
window.ACPower.style.display = &quot;none&quot;;
}
</script>

<a class=&quot;text&quot; href=&quot;../distribution&quot; onMouseOver=&quot;ACPowerOpen();&quot; OnMouseOut=&quot;ACPowerClose();&quot;>AC Power Distribution</a>
<a class=text name=&quot;ACPower&quot; style=&quot;display:none&quot;>test</a>

 
Here are a few reasons why it might not work :

1. try using divs instead of <a> for your elements.

2. Netscape 4 doesn't support the style.display property.

3. window.elementName.style.display is not a valid syntax. document.elementName works most of the time but if need be use a function like this one :

function getElement(id)
{
if (document.getElementById)
{
return document.getElementById(id)
}
else if (document.layers)
{
return document.layers[id]
}
else
{
return document.all[id]
}
}

Do you absolutly need Netscape 4 support?
 
In Netscape, they don't make the HTML elements global. Although JavaScript veterans might like it better, it discourages n00bs from coding for Netscape.

Here's the code that I would suggest using rather than your code (IE4+, NS6):

[COLOR=aa0000]
Code:
<script type=&quot;text/javascript&quot;>
_show=function() {this.style.display=&quot;inline&quot;;};
_hide=function() {this.style.display=&quot;none&quot;;};
getLayer=document.all?function(id) {
 var t=document.all[id];
 return t.show=_show, t.hide=_hide, t;
}:
function(id) {
 var t=document.getElementById(id);
 return t.show=_show, t.hide=_hide, t;
};
</script>

<span class=&quot;text&quot; onmouseover=&quot;getLayer('ACPower').show();&quot; onmouseout=&quot;getLayer('ACPower').hide();&quot;>AC Power Distribution</span>
<span id=&quot;ACPower&quot; class=&quot;text&quot; style=&quot;visibility: hidden;&quot;>test</span>
[/color]
Code:
- UNIMENT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top