Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder feras_wilson's Avatar
    Join Date
    Jul 2005
    Location
    Sweden
    Posts
    129
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Layer style dont work!!

    If tag don't work, why??
    Code:
    <script>
    function hiddenandvalue() {
    if(mylayer.style.visibility='hidden')
    mytextarea.value="it hidden"
    }
    </script>
    <body onload="hiddenandvalue()">
    <textarea name="mytextarea"></textarea>
    
    <a href="#" onclick="mylayer.style.visibility='hidden'">Let layer be hidden</a>
    <div style="position: absolute; width: 100px; height: 100px; z-index: 1; left: 107px; top: 96px; visibility:visible" id="mylayer">
    my layer is now visible </div>
    </body>
    Please Help!!

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,467
    Thanks
    3
    Thanked 495 Times in 482 Posts
    = assign
    == equality

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script>
    function hiddenandvalue() {
    if(mylayer.style.visibility=='hidden')
     mytextarea.value="it hidden"
    }
    </script>
    <body onload="hiddenandvalue()">
    
    <textarea name="mytextarea"></textarea>
    
    <a href="#" onclick="mylayer.style.visibility='hidden'">Let layer be hidden</a>
    <div style="position: absolute; width: 100px; height: 100px; z-index: 1; left: 107px; top: 96px; visibility:visible" id="mylayer">
    my layer is now visible </div>
    </body>
    
    </html>

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    and you should use the standard DOM notation, not the IE only shortcuts, to achieve a cross-browser code

    document.getElementById('mylayer').style.visibility
    ...
    document.getElementsByName('mytextarea')[0].value

    On the other hand I don't see the useness of the code, especially that called onload. It is useless, as onload always the element is visible.

    What is in fact you aim?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Regular Coder feras_wilson's Avatar
    Join Date
    Jul 2005
    Location
    Sweden
    Posts
    129
    Thanks
    1
    Thanked 0 Times in 0 Posts

    thanks

    thanks


  •  

    Posting Permissions

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