Setting: empty as iframe source has side effects in IE

I have a JS code that creates a hidden iframe with src="about:blank"

(so I don't load the content of the iframe unless the user clicks to open it), and when the user wants to see the content of the file, I just change the src

iframe.

The whole code will be too much to paste, but the essence is as follows:

// executed on document ready
iframeView = document.createElement('iframe')
iframeView.src = "about:blank"

// executed when the user clicks the button to show the iframe
iframeView.src = "http://example.com/some-url

      

However, sometimes (sometimes the keyword - that is about 4/5 times), in IE, the page inside the iframe throws an error and doesn't execute any JS on that page:

Origin about: Not found in the Access-Control-Allow-Origin header.

I suppose it has something to do about:blank

with which I am setting in pageload. But why? And why only on IE?

Edit: Tried a setup src=""

that got rid of this error, but the JS on the iframe content page still doesn't work.

+3


source to share





All Articles