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!

can't seem to get onMouseOut to work with Opera... 1

Status
Not open for further replies.

Jakobud

Technical User
Mar 9, 2001
51
US
Anyone tried this? I wrote a little javascript to swap the visiblity of two layers for a mouseover type of effect. The onMouseOver works, but the onMouseOut doesn't. I'm pretty sure it is the actual onMouseOut command that is the problem. By the way, I'm talking about the Opera browser here...anyone ever experienced this problem?

Jake
 
Well here is the javascript:

<script language=&quot;JavaScript1.2&quot;>

function toggleVisibility(id_hide,id_show) {
if (document.getElementById) {
eval(&quot;document.getElementById(id_hide).style.visibility = \&quot;&quot; + 'hidden' + &quot;\&quot;&quot;);
eval(&quot;document.getElementById(id_show).style.visibility = \&quot;&quot; + 'visible' + &quot;\&quot;&quot;);
} else {
if (document.layers) {
document.layers[id_hide].visibility = 'hidden';
document.layers[id_show].visibility = 'show';
} else {
if (document.all) {
eval(&quot;document.all.&quot; + id_hide + &quot;.style.visibility = \&quot;&quot; + 'hidden' + &quot;\&quot;&quot;);
eval(&quot;document.all.&quot; + id_show + &quot;.style.visibility = \&quot;&quot; + 'visible' + &quot;\&quot;&quot;);
}
}
}
}

</script>

Basically, this code is used so when you rollover a certain area of an image map, one layer is hidden and another is shown in it's place. Then when you move the mouse off the area, the first layer is shown and the second one is hidden, back to how it was originally. Here is the html:

<area shape=&quot;poly&quot; coords=&quot;513,346,494,340,&quot; href=&quot;#&quot; onMouseOver=&quot;toggleVisibility('brianp_1','brianp_2')&quot; onMouseOut=&quot;toggleVisibility('brianp_2','brianp_1')&quot; >

any help would be appreciated...or if anyone knows a better 'more compatible' way of doing this i'd appreciate it also. Because this code works fine in IE. Just not in Opera.

jake
 
I don't see any problem in your code, except the quotes parts. Instead of this:

eval(&quot;document.getElementById(id_hide).style.visibility = \&quot;&quot; + 'hidden' + &quot;\&quot;&quot;);
eval(&quot;document.getElementById(id_show).style.visibility = \&quot;&quot; + 'visible' + &quot;\&quot;&quot;);

I always write this:

document.getElementById(id_hide).style.visibility = &quot;hidden&quot;;
document.getElementById(id_show).style.visibility = &quot;visible&quot;;

It always works for Opera and Mozilla.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top