Joho the BlogRefresh an iframe in IE? Anyone? - Joho the Blog

Refresh an iframe in IE? Anyone?

I’ve googled until I’m gaga, but I can’t find the javascript code that will refresh an iframe from the server without refreshing the rest of the page. For this app I am using — forgive me — IE 7.0. Yes, I know iframes are not In, but I don’t know of another way to do picture-in-picture, so to speak, where the page being displayed is scrollable.

The iframe itself looks like this:

<iframe id=”browse” src=”” width=’100%’ height=’600px’ style=”display:block;”></iframe>

To refresh it, I’ve tried the following (and many variations of each):

var fr=document.getElementById(‘browse’);





Some of these do nothing. Some refresh the entire page, including the iframe. None refreshes only the iframe, forcing a reload from the server. Although nothing hangs on the project, I’ve now spent several hours trying to solve this little problem. Ack.

What is the vector of my particular dumbness this time? I’m sure it’s something embarrassing. But it’ll be worth displaying my ignorance yet again if someone knows the magic incantation that will end my misery… [Tags: ]

Previous: « || Next: »

19 Responses to “Refresh an iframe in IE? Anyone?”

  1. Via javascript, set the URL that the iFrame points to the same URL..

  2. James, isn’t that what





    None of them refresh only the iframe.

  3. How about adding a unique query string to make the browser reload it?

    fr.src = ‘’ + Math.random();

  4. IE, IFRAMEs, and updating contents are a minefield in a maze of twisty little passages, all alike. Adding the random # to the src url *should* help, but…

    Some years back I got dragged into an application like you describe but with IE5.5 and IE6. It looked like a caching issue but I wasn’t able to defeat it. Ended up changing the browser(s) to check for newer versions on every visit to the page.
    (Tools –> Internet Options –> General:Temporary Internet Files: Settings –> Check for newer etc)
    Don’t recommend making this change but I don’t use IE for normal browsing so there’s no terrible side effects.

    This might work: nuke the IFRAME and rebuild it from scratch every time you want to refresh. Doesn’t have to be an enormous task. Put the working IFRAME in an id’ed DIV. Deleting it can be as simple as:

    var oDiv = document.getElementById(‘myDiv’);
    var oIf = oDiv.getElementsByTagName(‘iframe’).item(0);
    oDiv.removeChild( oIf );

    Replacing it can be simple too if you add a template IFRAME to your page that is just like the IFRAME you want to work with. Then:

    oIf = templateIf.cloneNode(true);
    oDiv.appendChild( oIf );

    …and Bob’s your uncle.

  5. Delete old by:
    var fr=document.getElementById(‘browse’);
    if(fr!=null) document.getElementById(“framedivid”).removeChild(fr);

    After delete the old one, just adding iframe code to innerHTML. It is as simple as:
    var iframehtml=”<iframe id=’browser’ src=…></iframe>”;



  6. This worked for me in both IE 6 and Firefox. This is a JSP, but if you remove the sole tag, it will be pure HTML. The tags are useful in validating because they show the system time. I found this sensitive to whether I refresh using setTimeout(…) or directly, so I would suggest first copying it exactly and then tinkering.

    UNFORTUNATELY YOUR COMMENT BOX HIDES HTML, so it is up to you to extract the hidden html from the following.

    iframe container

    function loadiframe () {
    var myiframe = document.getElementById(“myiframe”);
    myiframe.contentWindow.location = “iframe.jsp”;
    setTimeout(loadiframe, 0);
    setTimeout(loadiframe, 3000);



    setTimeout(function () {parent.loadiframe()}, 5000);


  7. never mind… your comment box completely swallowed and eliminated my html, so there’s no easy way to post the exact solution… email me if what’s posted is not sufficient for you.

  8. here is a line that works on click, you can however change the trigger

    [iframe id=”quicksee” src=”somePage.html”][/iframe]
    [input type=”button” value=”refresh” onClick=”document.getElementById(‘quicksee’).contentWindow.location.reload()”]

    i changed the “>” for “[]” since it wouldnt display them somehow in the comment

  9. sdfgsdg

  10. Hi!rvtn! otyqd egxfn uyquj dipra

  11. Hi! sojmp hudbj whiyz jrllg

  12. Hi! rpjnj vgjmz qpkyw reasp

  13. It seems document.getElementById(“some_iframes_id”).contentWindow.location.reload(true); works perfectly in IE 7 and other web browsers… “contentWindow” is the important part here altso.

  14. i want to refresh the page from a DIV after deleting a div in the same page, the DOM is not refreshing in IE, but in FF, it is working fine,can any one help-out.

  15. document.getElementById(“id_of_iframe”).contentWindow.location.reload();

    This works in IE 6 reloading content of an iframe only.

  16. I know, old subject, but WF*… Dang, you guys are making it sound difficult !!!!

    In IFRAME, put…

  17. (DARN)

  18. I give up, i tried. I even tried the CODE trick, but it will not let me put the code in here. Im gone.

  19. dsadsad

Web Joho only

Comments (RSS).  RSS icon