Auto Refresh Iframe?

Discussion in 'JavaScript' started by Lipgut, Oct 25, 2008.

  1. #1
    Ok I need a iframe that auto refresh's only the iframe. The iframe leads to a .txt file. The iframe I have now looks something like this:

    <iframe name='iframe1' src='/status.txt' frameborder="0" frameborder="0" width='80' height='40'></iframe>
    PHP:
    I need that to auto refresh every 5 seconds or so. I would like it to be in java cause that type of coding seems to work in all browsers :p but I know NOTHING about java accept how to put it into the .html . So I would really like your help!

    ( I can't find a working source anywhere on the internet so you guys are my last hope :D No preasure :p )
     
    Lipgut, Oct 25, 2008 IP
  2. imphpguru

    imphpguru Active Member

    Messages:
    439
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #2
    Hi,
    I guess this should work.

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <script language="javascript">
    function reloadIframe()
    	{
    		document.getElementById('iframe1').src='/status.txt';
    	}
    </script>
    </head>
    
    <body onload="reloadIframe();">
    <iframe name='iframe1' src='/status.txt' frameborder="0" frameborder="0" width='80' height='40' id="iframe1"></iframe>
    </body>
    </html>
    
    Code (markup):
    Thanks

    imphpguru
     
    imphpguru, Oct 26, 2008 IP
  3. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #3
    You have to use settimeout to make a loop :)
     
    elias_sorensen, Oct 27, 2008 IP
  4. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #4
    It will be setInterval()

    setInterval("YOUR CODE OR REFRESH FUNCTION();",5000)
    Code (markup):
     
    ads2help, Oct 30, 2008 IP
  5. tdsii

    tdsii Member

    Messages:
    175
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    #5
    just use:
    this will make the iframe refresh every 5 seconds.
     
    tdsii, Oct 31, 2009 IP
  6. nathan_s

    nathan_s Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    doesn't this also refresh the whole page? i'm lost here (
     
    nathan_s, Nov 2, 2009 IP