1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hiding Something for 30/60 seconds?

Discussion in 'HTML & JavaScript' started by Essence19, Feb 13, 2011.

  1. Essence19

    Essence19 BANNED BANNED

    Joined:
    Aug 10, 2010
    Messages:
    830
    Likes Received:
    352
    How do i get my website to hide a button for 30 to 60 seconds when the page loads,when the user arrives on the page the button is hidden and only shows up after 30 or 60 seconds ,is that possible?
     
  2. squark

    squark Junior Member

    Joined:
    May 22, 2008
    Messages:
    156
    Likes Received:
    1,207
    I would recommend JavaScript w/ jQuery. Create a div that is hidden (using styles) that contains the button. Then use setTimeout for the delay you want. In the setTimeout callback use the jQuery show() method to unhide your button div.

    It's pretty straightforward.
     
  3. noiddemo

    noiddemo Junior Member

    Joined:
    May 17, 2009
    Messages:
    104
    Likes Received:
    19
    do you use wordpress?
     
  4. eskimo

    eskimo Regular Member

    Joined:
    Dec 1, 2008
    Messages:
    474
    Likes Received:
    178
    Code:
    <script>
    	$(document).ready(function(){
    		function showButton(){
    			$('.mybutton').fadeIn();		
    		}
    		
    		setTimeOut(showButton(),30000);
    	});
    </script>
    
    <input type="button" class="mybutton" />
    Haven't tested it, should work though. You will need jQuery
     
    • Thanks Thanks x 1
  5. sirgold

    sirgold Supreme Member

    Joined:
    Jun 25, 2010
    Messages:
    1,260
    Likes Received:
    645
    Occupation:
    Busy proving the Pareto principle right
    Location:
    A hot one
    I'm on "programming" fire today in a lot of different languages lol No need to add overhead with jquery, IMO. Something as simple as this will do. You just need to change which FUNCTION needs to be delayed (in milliseconds...) instead of this sample:

    Code:
    document.getElementById('delay').innerHTML='Here I am!'
    Cheers.

    Code:
    
    <html>
    <body>
    
    <script>
    setTimeout("document.getElementById('delay').innerHTML='Here I am!'",2500);
    </script>
    
    Delayed fun...
    <hr>
    <div id="delay"></div><br>
    
    </body>
    </html>
    
     
    • Thanks Thanks x 1
  6. Essence19

    Essence19 BANNED BANNED

    Joined:
    Aug 10, 2010
    Messages:
    830
    Likes Received:
    352
    another question,How do I get the page to automatically redirect to another site after 60 seconds?
     
  7. newyorkpride

    newyorkpride Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 26, 2008
    Messages:
    156
    Likes Received:
    59
    For the life of me, I can't figure out why people don't google these types of things before spending the time to post a post. All your questions are answered on google. I haven't tried myself but guaranteed if you search for "timed redirect" you will get your answer on the first page, if not the first website. This will save you alot of time. Google EVERYTHING first.
     
  8. sirgold

    sirgold Supreme Member

    Joined:
    Jun 25, 2010
    Messages:
    1,260
    Likes Received:
    645
    Occupation:
    Busy proving the Pareto principle right
    Location:
    A hot one
    A few ways.

    JavaScript

    Code:
    <script>
    function redirect(){
    window.location.href = "http://your-redir-site/";
    }
    window.onload = setTimeout("redirect()", 60000);
    </script>
    
    HTML (between head tags)

    Code:
    <meta http-equiv="refresh" content="60;url=http://your-redir-site/">
    
    PHP

    Code:
    <?php
    header('Refresh: 60; url=http://your-redir-site/'); 
    ?>