Search code examples
javascripthtmlfacebookinternet-explorerrefresh

Refresh page within an iframe


I have an app (facebook canvas app, facebook displays the app in an iframe)

When the user clicks on a link I want to be able to refresh the page.

the code i m using to refresh the page is as follows:

window.location.reload(true);

With firefox this works fine, it only refreshes the current page within the iframe. So i m happy.

With IE, the whole page is being refreshed which causes the user to go the beginning of the app.

How can i avoid that?

I just want refresh the current page not the current url.

apps.facebook.com/foo/

is the app URL and within URL user clicks on a link go to a page, then within that Page i need to refresh that page to update some counters. but when i refresh the whole request goes to apps.facebook.com/foo/

any ideas?


Solution

  • As stated in http://www.hyperorg.com/blogger/2007/03/24/refresh-an-iframe-in-ie-anyone/

    HTML

    <div id="wrapper"></div>
    

    Javascript

    function reload () {
        var fr=document.getElementById('tehframe');
        if(fr!=null) document.getElementById("wrapper").removeChild(fr);
        var iframehtml="<iframe id='tehframe' src=…></iframe>";
        document.getElementById("wrapper").innerHTML=iframehtml;
    }
    

    Then just call reload() at the beginning and whenever you want to load it.