1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Div tag which is hidden in the first 3 seconds

Discussion in 'JavaScript' started by Jazu79, Nov 28, 2008.

  1. #1
    I need div tag which is hidden in the first 3 seconds, and will appear automatically, and will remain visible.

    I know that it can be achieved for example javascript, but how? I have not found anything similar.

    Thank you in advance! :)
     
    Jazu79, Nov 28, 2008 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <script type='text/javascript'>
    function showDiv()
    {
      document.getElementById('mydiv').style.display = 'inline';
    }
    
    setTimeout("showDiv()", 3000);
    </script>
    <div id='mydiv' style='display: none'>content</div>
    
    Code (markup):
     
    xlcho, Nov 28, 2008 IP
  3. Jazu79

    Jazu79 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oh, great! I love you! Thank you very much!!
     
    Jazu79, Nov 28, 2008 IP
  4. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Glad I can help :)
     
    xlcho, Nov 28, 2008 IP
  5. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Its better performance wise to use a closure, not a string for the first parameter.
     
    MMJ, Nov 28, 2008 IP
  6. irunbackwards

    irunbackwards Peon

    Messages:
    791
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #6
    <script type='text/javascript'>
    function showDiv()
    {
      if(document.getElementById('mydiv').style.display = 'inline') { document.getElementById('mydiv').style.display = 'none'; } else { document.getElementById('mydiv').style.display = 'inline'; }
    }
    
    setInterval("showDiv()", 3000);
    </script>
    <div id='mydiv' style='display: none'>content</div>
    Code (markup):
    The above code would hide/show the same div every 3 seconds, instead of just once.
     
    irunbackwards, Nov 28, 2008 IP
  7. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Nothing's impossible, you know. But what Jazu was asking for was just to show the div, i guess the user would want to do something with it when it shows, so there is no need to flash (show, hide, show...) it constantly :)

    About the performance.. I doubt there would be any difference for such a small piece of code, but in general you are right, MMJ, my bad :)
     
    xlcho, Nov 29, 2008 IP