aleclofabbro aleclofabbro - 1 year ago 99
HTML Question

Nested iframe won't load

In a html document i append an

in the body (no CORS, e.g. same url).

In the appended
i attempt to do the same thing:

the nested
element is successfully appended to the parent
body, but the content won't load.

I googled without success for info about this issue,

i made plunk that simply shows it.

Can anybody tell me where's the problem?

Answer Source

your code is doing what you are expecting, please try to inspect your page DOM, when you press the button the child iframe is added inside you parent iframe.


the browser do not display an iframe inside an iframe with the same SRC, this is becouse the iframe loaded has the same source, this script else works fine becouse the url is changed every time appending a querystring

  var d = new Date();
  var n = d.getTime();
  var iframe = document.createElement('iframe');
  iframe.setAttribute('src', location.href + "?" + n ); = '100%'; = '800px';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download