Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: refresh iframe

  1. #1
    New Coder
    Join Date
    Dec 2007
    Posts
    43
    Thanks
    1
    Thanked 0 Times in 0 Posts

    refresh iframe

    hi ,

    i have iframe on my web page which shows the web camera .
    I want that iframe should refresh every 5 seconds.

    Can anyone help me

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    You need javascript to achieve this put this in your head

    Code:
    <script type="text/javascript">
     function reloadiframe () {
        setTimeout("go_now()",5000);
        }
    
        function go_now () {
            
        parent.frames['myiframe'].location.reload(true);
        }
    </script>
    make sure your iframe has name="myiframe"

    Code:
    <iframe src="http://example.com" name = "myiframe" onLoad="reloadiframe();">
    Though the onload is supported in most current browsers (IE5.5+, Firefox, Safari, Opera) it's not actually correct. Not sure of a better way though. Also this script will only work if both your parent document and iframe document are hosted on the same domain?

    If its not on same domain there's some information of what to do here http://www.dyn-web.com/tutorials/iframes/
    Last edited by timgolding; 04-06-2009 at 10:00 AM.
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    84
    Thanks
    5
    Thanked 0 Times in 0 Posts
    why don't you just add this in the iframe window:

    Code:
    <meta http-equiv="REFRESH" content="5;url=theurltoyouriframe">


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •