I\'ve made some experiments in Chrome but I\'m not sure so I need a confirmation :
Am I correct in thinking that iframes and frames have a separate JavaScript contex
Well, they just have different global objects and global scope. However, if they are in the same domain you can run code in one from another. But if you were to do this (inside parent window):
document.getElementById( "myiframe" ).contentWindow.window.globalArray = [];
Which creates a global variable globalArray
inside the iframe's global scope.
and then inside the iframe
console.log( globalArray instanceof Array );
will return false
because Array
refers to the iframe's Array
constructor. You'd have to do
console.log( globalArray instanceof top.Array );
where top
refers to the container window global object.
jsfiddle: http://jsfiddle.net/EFbtN/