Problems setting style attrabutes of multiple layers

Discussion in 'Javascript' started by Eclectic, Sep 23, 2004.

  1. Eclectic

    Eclectic Guest

    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');">
     
    Eclectic, Sep 23, 2004
    #1
    1. Advertising

  2. 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.
     
    Richard Cornford, Sep 29, 2004
    #2
    1. Advertising

  3. 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.
     
    Thomas 'PointedEars' Lahn, Oct 10, 2004
    #3
  4. 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.
     
    Richard Cornford, Oct 10, 2004
    #4
  5. 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.
     
    Thomas 'PointedEars' Lahn, Oct 10, 2004
    #5
  6. 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.
     
    Richard Cornford, Oct 10, 2004
    #6
  7. 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
     
    Thomas 'PointedEars' Lahn, Oct 10, 2004
    #7
  8. 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.
     
    Richard Cornford, Oct 10, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. metsys
    Replies:
    1
    Views:
    775
    =?Utf-8?B?RFdT?=
    May 4, 2006
  2. Ken Varn
    Replies:
    0
    Views:
    470
    Ken Varn
    Apr 26, 2004
  3. HD
    Replies:
    0
    Views:
    73
  4. Stuart

    Layers, getting setting position

    Stuart, Jul 31, 2004, in forum: Javascript
    Replies:
    0
    Views:
    97
    Stuart
    Jul 31, 2004
  5. Dave
    Replies:
    0
    Views:
    142
Loading...

Share This Page