Problems setting style attrabutes of multiple layers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eclectic

    Problems setting style attrabutes of multiple layers

    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.a ll[...].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,ob j){
    if(meth=="show" ){
    document.all[obj].style.visibili ty = 'visible';
    }else if(meth=="hide" ){
    document.all[obj].style.visibili ty = '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="mainTitl e">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="mainTitl e">Some Text</span></div>
    <!-- -->

    <img src="q.gif" width="10" height="10"
    onMouseOver="he lpWin('show','b bc');"
    onMouseOut="hel pWin('hide','bb c');">

    <img src="q.gif" width="10" height="10"
    onMouseOver="he lpWin('show','t oc');"
    onMouseOut="hel pWin('hide','to c');">
  • Ranbir Kaur

    #2
    Re: Problems setting style attrabutes of multiple layers

    Hi,

    In article <c7516dd5.04092 30745.7e16255a@ posting.google. com>, Eclectic wrote:
    [color=blue]
    > solid balck;[/color]

    it's definitely dangerous to use 'solid balck;'. I'd recommend a spell checker. Dreamweaver does a good job
    for that kind of things.

    For the other problem of yours,
    [color=blue]
    > The problem is, I get an error telling me "document.a ll[...].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[/color]

    Use this script, I don't remember where I got it from, and lost the copyright message, thanks to the author
    anyway:

    --------
    function toggleVisibilit y(id, NNtype, IEtype, W3Ctype) {
    if (document.getEl ementById) {
    eval("document. getElementById( id).style.visib ility = \"" + W3Ctype + "\"");
    } else {
    if (document.layer s) {
    document.layers[id].visibility = NNtype;
    } else {
    if (document.all) {
    eval("document. all." + id + ".style.visibil ity = \"" + IEtype + "\"");
    }
    }
    }
    ------------------

    you use it like:

    onMouseOut="tog gleVisibility(' bcc','hidden',' hidden','hidden ');
    onMouseOver="to ggleVisibility( 'toc','show','v isible','visibl e');

    you can use it for any number of objects, for any kind of event. It's very convenient and works with (AFAIK)
    every browser.

    Ranbir


    Comment

    • Richard Cornford

      #3
      Re: Problems setting style attrabutes of multiple layers

      Ranbir Kaur wrote:
      <snip>[color=blue]
      > if (document.getEl ementById) {
      > eval("document. getElementById( id).style.visib ility = \"" +
      > W3Ctype + "\"");[/color]
      <snip>
      This has got be the most futile use of - eval - posted in a long time:-

      document.getEle mentById(id).st yle.visibility = W3Ctype;

      Richard.


      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Problems setting style attrabutes of multiple layers

        Richard Cornford wrote:
        [color=blue]
        > Ranbir Kaur wrote:
        > <snip>[color=green]
        >> if (document.getEl ementById) {
        >> eval("document. getElementById( id).style.visib ility = \"" +
        >> W3Ctype + "\"");[/color]
        > <snip>
        > This has got be the most futile use of - eval - posted in a long time:-
        >
        > document.getEle mentById(id).st yle.visibility = W3Ctype;[/color]

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

        var t;
        if ((t = typeof document.getEle mentById) == "function"
        || (t == "object" && document.getEle mentById))
        {
        var o = document.getEle mentById(id), s;
        if (o
        && typeof o.style != "undefined"
        && typeof o.style.visibil ity != "undefined" )
        {
        o.style.visibil ity = 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.

        Comment

        • Richard Cornford

          #5
          Re: Problems setting style attrabutes of multiple layers

          Thomas 'PointedEars' Lahn wrote:[color=blue]
          > Richard Cornford wrote:[color=green]
          >> Ranbir Kaur wrote:
          >> <snip>[color=darkred]
          >>> if (document.getEl ementById) {
          >>> eval("document. getElementById( id).style.visib ility = \"" +
          >>> W3Ctype + "\"");[/color]
          >> <snip>
          >> This has got be the most futile use of - eval - posted
          >> in a long time:-
          >>
          >> document.getEle mentById(id).st yle.visibility = W3Ctype;[/color]
          >
          > Not this way, see <http://www.pointedears .de/scripts/test/whatami>.
          > Instead write:[/color]
          <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.


          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: Problems setting style attrabutes of multiple layers

            Richard Cornford wrote:
            [color=blue]
            > Thomas 'PointedEars' Lahn wrote:[color=green]
            >> Richard Cornford wrote:[color=darkred]
            >>> Ranbir Kaur wrote:
            >>> <snip>
            >>>> if (document.getEl ementById) {
            >>>> eval("document. getElementById( id).style.visib ility = \"" +
            >>>> W3Ctype + "\"");
            >>> <snip>
            >>> This has got be the most futile use of - eval - posted
            >>> in a long time:-
            >>>
            >>> document.getEle mentById(id).st yle.visibility = W3Ctype;[/color]
            >>
            >> Not this way, see <http://www.pointedears .de/scripts/test/whatami>.
            >> Instead write:[/color]
            > <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.[/color]

            I commented on your inappropriate correction.


            PointedEars
            --
            PROZAC: Sometimes you feel like a nut, sometimes you don't.

            Comment

            • Richard Cornford

              #7
              Re: Problems setting style attrabutes of multiple layers

              Thomas 'PointedEars' Lahn wrote:[color=blue]
              > Richard Cornford wrote:[color=green]
              >> Thomas 'PointedEars' Lahn wrote:[color=darkred]
              >>> Richard Cornford wrote:
              >>>> Ranbir Kaur wrote:
              >>>> <snip>
              >>>>> if (document.getEl ementById) {
              >>>>> eval("document. getElementById( id).style.visib ility = \"" +
              >>>>> W3Ctype + "\"");
              >>>> <snip>
              >>>> This has got be the most futile use of - eval - posted
              >>>> in a long time:-
              >>>>
              >>>> document.getEle mentById(id).st yle.visibility = W3Ctype;
              >>>
              >>> Not this way, see http://www.pointedears.de/scripts/test/whatami
              >>> Instead write:[/color]
              >> <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.[/color]
              >
              > I commented on your inappropriate correction.[/color]

              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.


              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: Problems setting style attrabutes of multiple layers

                Richard Cornford wrote:
                [color=blue]
                > Thomas 'PointedEars' Lahn wrote:[color=green]
                >> Richard Cornford wrote:[color=darkred]
                >>> Thomas 'PointedEars' Lahn wrote:
                >>>> Richard Cornford wrote:
                >>>>> Ranbir Kaur wrote:
                >>>>> <snip>
                >>>>>> if (document.getEl ementById) {
                >>>>>> eval("document. getElementById( id).style.visib ility = \"" +
                >>>>>> W3Ctype + "\"");
                >>>>> <snip>
                >>>>> This has got be the most futile use of - eval - posted
                >>>>> in a long time:-
                >>>>>
                >>>>> document.getEle mentById(id).st yle.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.[/color]
                >>
                >> I commented on your inappropriate correction.[/color]
                >
                > Are you proposing that I did not post the code for the equivalent
                > operations without the eval?[/color]

                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

                Comment

                • Richard Cornford

                  #9
                  Re: Problems setting style attrabutes of multiple layers

                  Thomas 'PointedEars' Lahn wrote:[color=blue]
                  > Richard Cornford wrote:[color=green]
                  >> Thomas 'PointedEars' Lahn wrote:[/color][/color]
                  <snip>[color=blue][color=green][color=darkred]
                  >>> I commented on your inappropriate correction.[/color]
                  >>
                  >> Are you proposing that I did not post the code for the
                  >> equivalent operations without the eval?[/color]
                  >
                  > 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"?[/color]

                  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.


                  Comment

                  Working...