views:

22

answers:

2

Hi all,

I tried to run a line of code as the following:

document.getElementById('frame0').contentDocument.location.reload(true); to force iframe to refresh or reload but I got the error like "permission denied" in firefox. Does anyone know why? and help to offer a solution? Thanks!

+1  A: 

It is probably because of crossdomain issues - looks like your iframes content is from another domain as your mainframe (from which you run your js code). FF is very restrictive concerning crossdomains.

Thariama
A: 

You can't reload a document that comes from a different hostname, due to the Same origin policy, which applies in all browsers.

You would have to remove the iframe from the page and replace it with a new one:

var iframe= document.getElementById('frame0');
var newiframe= document.createElement('iframe');
newiframe.src= iframe.src;
iframe.parentNode.replaceChild(newiframe, iframe);

However this will load the original src of the <iframe>, which won't be the same as the current location if the user has navigated the page since.

bobince