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.

Delay Iframe Timer

Discussion in 'HTML & Website Design' started by tryingtolearn, May 6, 2009.

  1. #1
    Hello,

    I was wondering if I can have a timer, or delay before my IFrame Loads? The IFrame code I am using is below

    <iframe src="mysite.com" width="100%" height="1300" scrolling="no" frameborder="0" id="myframe" style="background-color: #ffffff;" allowtransparency="true" border="0"></iframe>
    Code (markup):
    I need something that will work with the current coding I have for color, size, width, and so on.

    Thanks for any help.
     
    tryingtolearn, May 6, 2009 IP
  2. makesyouclick

    makesyouclick Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There are various ways to do it:

    Method 1
    
    <iframe src="http://website.com/iframe1.htm"></iframe>
    
    Code (markup):
    
    <meta http-equiv="refresh" content="10;url=http://website.com/iframe2.htm" />
    
    Code (iframe1.htm):
    Method 2 - have a javascript with delay followed by document.write(the iframe code);

    Method 3 - use PHP sleep(); to delay the iframe execution

    etc.
     
    makesyouclick, May 6, 2009 IP
  3. tryingtolearn

    tryingtolearn Peon

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I came up with a fix which is basically the same thing using JavaScript but I have CSS with it as well for formatting. I will paste the code below in case anyone else has this question. You can add or delete options in the CSS part to customize it more. "setTimeout(loadfunction,10000)" is telling the browser to delay loading the IFrame for ten seconds.

    //JavaScript//
    <script type="text/javascript">
     window.onload = function() {
     	setTimeout(loadfunction,10000)
     }
     function loadfunction() {
     	document.getElementById("myiframe").src = "http://www.google.com"
     }
     </script>
    HTML:
    //CSS//
    <style type="text/css">
    <!--
    #myiframe {
    	height: 600px;
    	width: 100%;
    	border: 0; 
            background-color: #000;
    	
    }
    -->
     </style>
    HTML:
    //IFrame//
    <iframe id="myiframe"></iframe>
    HTML:
     
    tryingtolearn, May 6, 2009 IP