Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Problems setting style attrabutes of multiple layers

Reply
Thread Tools

Problems setting style attrabutes of multiple layers

 
 
Eclectic
Guest
Posts: n/a
 
      09-23-2004
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');">
 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      09-29-2004
Ranbir Kaur wrote:
<snip>
> 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.


 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-10-2004
Richard Cornford wrote:

> Ranbir Kaur wrote:
> <snip>
>> 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;


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
--
Life is like a french fry. It gets cold, it gets soggy, and it gets limp if
you let it lying around too long.
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      10-10-2004
Thomas 'PointedEars' Lahn wrote:
> Richard Cornford wrote:
>> Ranbir Kaur wrote:
>> <snip>
>>> 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;

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

<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.

Richard.


 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-10-2004
Richard Cornford wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Richard Cornford wrote:
>>> Ranbir Kaur wrote:
>>> <snip>
>>>> 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;

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

> <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
--
PROZAC: Sometimes you feel like a nut, sometimes you don't.
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      10-10-2004
Thomas 'PointedEars' Lahn wrote:
> Richard Cornford wrote:
>> Thomas 'PointedEars' Lahn wrote:
>>> Richard Cornford wrote:
>>>> Ranbir Kaur wrote:
>>>> <snip>
>>>>> 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;
>>>
>>> Not this way, see http://www.pointedears.de/scripts/test/whatami
>>> Instead write:

>> <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.


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.


 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-10-2004
Richard Cornford wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Richard Cornford wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>> Richard Cornford wrote:
>>>>> Ranbir Kaur wrote:
>>>>> <snip>
>>>>>> 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;
>>>>
>>>> Not this way, see http://www.pointedears.de/scripts/test/whatami
>>>> Instead write:
>>> <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.

>
> 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
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      10-10-2004
Thomas 'PointedEars' Lahn wrote:
> Richard Cornford wrote:
>> Thomas 'PointedEars' Lahn wrote:

<snip>
>>> I commented on your inappropriate correction.

>>
>> 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"?


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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subnets between core and access/distribution layers & routing between layers J Cisco 0 12-13-2006 08:38 PM
Exception Handling Techniques for ASP.NET Application with Multiple Layers metsys ASP .Net 1 05-04-2006 01:34 PM
setting perlio layers (e.g., utf8) on "magic" ARGV file handle Dave Perl Misc 0 06-11-2005 01:18 AM
Layers, getting setting position Stuart Javascript 0 07-31-2004 07:53 AM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM



Advertisments