SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change the Visibility??

    Im trying to change the visibility of a div from hidden to visible "onMouseOver" ...

    This isn't working...any ideas..

    Here's my code:

    <html>

    <head>

    <script language="javascript">

    function setIDProperty( id, property, value )
    {
    document.all[id].style[property] = value;
    }


    function show() {

    setIDProperty("test", "visiblity", "visible");
    }

    </script>

    <style type="text/css">

    #test { position: relative; visibility: hidden; }

    </style>

    </head>
    <body>


    <a href="http://www.adobe.com" onMouseOver="show();">Link 1</a> <br><br>

    <div id="test">asdfdsdsds</div>


    </body>
    </html>

  2. #2
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The style object is not a collection, so you cannot access it as if it were (using the square brraces - []). Do this instead:

    Code:
    document.all[id].style.property=value;
    Rob Nolan
    Do or do not, there is no try.

  3. #3
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope...Tried that..No Luck.

  4. #4
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I wasn't my response was not complete. I was in a hurry to get to a meeting and should have just held off until later.

    You will have to use an eval to get it to work:
    Code:
    function show(id, property, value) { 
    	eval("document.all[id].style." + property + " = '" + value + "'");
    }
    I eliminated the setIDProperty function, as it is completely unneccessary.
    Rob Nolan
    Do or do not, there is no try.

  5. #5
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This will change the class on mousover:

    <div class="yourclass" onMouseOver="this.className='yourotherclass';" onMouseOut="this.className='yourclass';"></div>

    Never tried with id but it should be the same.

    Then specify the visibilty properties you want for yourclass & yourotherclass.

  6. #6
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi meztec,

    The following works for all 3 major browsers:

    function setIDProperty( id, property, value )
    {
    divObj = (document.all) ? document.all[id] : (document.getElementById) ? document.getElementById(id) : document.layers[id];

    divStyle = (document.layers) ? divObj : divObj.style;

    eval("divStyle." + property + " = '" + value + "'");
    }

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  7. #7
    SitePoint Addict
    Join Date
    Sep 2000
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers..

  8. #8
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    another way....

    <a href="#" onMouseOver="help.style.visibility='visible';" onMouseOut="help.style.visibility='hidden';">

    in Netscape change visible to show and hidden to hide.

    Sketch
    Aaron Brazell
    Technosailor




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •