How to hide a div on load?

Discussion in 'JavaScript' started by Kerosene, Jan 8, 2009.

  1. #1
    I want to make a "JavaScript Required" div that automatically hides if the user has JavaSscript enabled.

    So if the user has JS disabled, then the div will display, and show "JavaScript Required". For everyone else with JavaScript enabled, it will be hidden.

    How can I do this?
     
    Kerosene, Jan 8, 2009 IP
  2. manjifera

    manjifera Well-Known Member

    Messages:
    232
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    118
    #2
    here is the code!!

    <body onload="hjs()">
    <script language="javascript" type="text/javascript">
    function hjs()
    {
    document.getElementById("js").innerHTML = "";
    }
    </script>
    <div id="js">Please Enable Javascripting....</div>
    </body>
    HTML:




    if you find my post helpful try to donate! $ 1-2-3
     
    manjifera, Jan 8, 2009 IP
    Kerosene likes this.
  3. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #3
    Thanks manjifera, +REP :D
     
    Kerosene, Jan 8, 2009 IP
  4. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #4
    No JavaScript code is required to do this. Just add a <noscript> tag:
    <noscript><div>JavaScript Required</div></noscript>
    HTML:
     
    phper, Jan 8, 2009 IP
  5. whisucul

    whisucul Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That is so nice collection.Well after finding your this comment there is no need for any book reading search of last few years.I like your idea for distributing the books by years.
     
    whisucul, Dec 18, 2009 IP
  6. SIPHILP

    SIPHILP Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Best practice ^
     
    SIPHILP, Dec 19, 2009 IP
  7. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #7
    These days javascript is a MUST, having it disabled is just not an option. honestly, I wouldn't even bother.
     
    camjohnson95, Dec 20, 2009 IP