Welcome to WebmasterServe!

FREE TO JOIN! Join us now to engage in informative and friendly discussions about Webmastering, SEO, SEM, Internet Marketing, Programming, Graphic Design, Online Jobs and more. What are you waiting for? Ready to join our friendly community? It takes just one minute to register.

Dismiss Notice

Join WebmasterServe Forums 
Join the discussion! Have a better idea or an opinion? It takes just one minute to register Click Here to Join

Help Me/Question Delaying Appearance Of Items On Webpage

Discussion in 'Javascript and jQuery' started by lapunluyang, Jun 23, 2011.

Thread Status:
Not open for further replies.
  1. lapunluyang

    Yellow Belt

    Joined:
    Mar 14, 2011
    Messages:
    48
    Ratings:
    +0 / -0
    Any one know of javascript that can delay the appearance of a button or table for x seconds into the page loading?

    Ie the page all loads, while the optin box appear 10 seconds after.

    I could do it with iframe, ie set an iframe with a redirect in 10 seconds. but there must be a slicker way.

    Any help appreciated. thanks
     
  2. AdvanceByDesign

    White Belt

    Joined:
    Jul 28, 2011
    Messages:
    12
    Ratings:
    +0 / -0
    Hi lapunluyang,
    it's quite straight forward with Javascript:

    Give the table/object/div/fieldset/whatever you want to hide an ID (for example, id="my_div") and the following style attribute:

    Code:
    Select All
    style="display:none;"
    Then have a javascript run on the body onload event with a timeout to display it:

    HTML:
    Select All
    <body onload='Javascript:setTimeout("document.getElementById(\"my_div\").style.display=\"block\";", 5000);'>
    A complete example:

    HTML:
    Select All
    <html> <body onload='Javascript:setTimeout("document.getElementById(\"my_div\").style.display=\"block\";", 5000);'> <div style="display:none;" id="my_div">This is a test</div> </body> </html>
     
Thread Status:
Not open for further replies.

Share This Page