Problems setting style attrabutes of multiple layers

E

Eclectic

I have a couple of layers that are hidden.

When an image is moused over, I want to show the appropriate layer,
then hide it on mouseOut.

The problem is, I get an error telling me "document.all[...].style is
not an object" for whatever layer I have created first. It seems as
though when the second layer is created, it overwrites the first one
....

This has been driving me NUTS! Any suggestions?

Heres my code:

javascript :

function helpWin(meth,obj){
if(meth=="show"){
document.all[obj].style.visibility = 'visible';
}else if(meth=="hide"){
document.all[obj].style.visibility = 'hidden';
}
}

HTML :

<!-- -->
<div id="bcc" style="position:absolute; border: 1px solid balck;
left:420px; top:0px; width:300px; height:50px; z-index:1;
background-color: #FFFFFF; layer-background-color: #FFFFFF;
visibility: hidden;">
<span class="mainTitle">Some Text</span></div>
<!-- -->
<div id="toc" style="position:absolute; border: 1px solid balck;
left:420px; top:0px; width:300px; height:50px; z-index:2;
background-color: #FFFFFF; layer-background-color: #FFFFFF;
visibility: hidden;">
<span class="mainTitle">Some Text</span></div>
<!-- -->

<img src="q.gif" width="10" height="10"
onMouseOver="helpWin('show','bbc');"
onMouseOut="helpWin('hide','bbc');">

<img src="q.gif" width="10" height="10"
onMouseOver="helpWin('show','toc');"
onMouseOut="helpWin('hide','toc');">
 
R

Richard Cornford

Ranbir Kaur wrote:
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" +
W3Ctype + "\"");
<snip>
This has got be the most futile use of - eval - posted in a long time:-

document.getElementById(id).style.visibility = W3Ctype;

Richard.
 
T

Thomas 'PointedEars' Lahn

Richard said:
Ranbir Kaur wrote:

<snip>
This has got be the most futile use of - eval - posted in a long time:-

document.getElementById(id).style.visibility = W3Ctype;

Not this way, see <http://www.pointedears.de/scripts/test/whatami>.
Instead write:

var t;
if ((t = typeof document.getElementById) == "function"
|| (t == "object" && document.getElementById))
{
var o = document.getElementById(id), s;
if (o
&& typeof o.style != "undefined"
&& typeof o.style.visibility != "undefined")
{
o.style.visibility = W3Ctype;
}
}


PointedEars
 
T

Thomas 'PointedEars' Lahn

Richard said:
<snip>

This has nothing to do with the futility of the - eval - formulation
used. If you want to talk about the code design it would make most sense
to post a response to individual who designed it, not me.

I commented on your inappropriate correction.


PointedEars
 
R

Richard Cornford

Thomas said:
I commented on your inappropriate correction.

Are you proposing that I did not post the code for the equivalent
operations without the eval?

In any event, my post was not a correction it was an observation of
manifest futility. And frankly, referring me to your pathetic page on
feature detection, or posting your clunky and pedestrian feature
detection example, looks like trying to teach your grandmother to suck
eggs.

Richard.
 
T

Thomas 'PointedEars' Lahn

Richard said:
Are you proposing that I did not post the code for the equivalent
operations without the eval?

I am proposing that your correction is presenting a still
inappropriate approach, although it is better than using
eval(...). Don't you understand "Not this way"?


PointedEars
 
R

Richard Cornford

Thomas said:
I am proposing that your correction is presenting a still
inappropriate approach, although it is better than using
eval(...). Don't you understand "Not this way"?

And once again you have cut the part of my post where I stated that my
first post to this thread was an observation not a correction, and then
replied as if that statement had not been made.

Richard.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top