Well, they just have different global objects and a global scope. However, if they are in the same domain, you can run the code one by one. But if you have to do this (inside the parent window):
document.getElementById( "myiframe" ).contentWindow.window.globalArray = [];
Which creates the global variable globalArray inside the global iframe.
and then inside the iframe
console.log( globalArray instanceof Array );
will return false because Array refers to the iframe constructor of the Array . You will need to do
console.log( globalArray instanceof top.Array );
where top refers to the global container window object.
jsfiddle: http://jsfiddle.net/EFbtN/
source share