I have this script for Gmail. It works inside an canvas_frameiframe.
I want to get the handle of the parent document using parent.document. But on Chrome, it tells me that it is undefined. Works fine in Firefox, but explodes in Chrome.
So how exactly do I get the handle of the parent document, from inside the iframe, in Chrome.
Chrome ver: 11.0.686.3
Here's the code that doesn't work:
function init() {
try {
if(parent == null) {
console.log(typeof parent);
window.setTimeout(init, 200);
return;
}
} catch(e) { console.log(e) }
}
This part simply displays undefinedendlessly in the log window.
Here a script test is run that gives the same result. He displays undefined, and then cQendlessly.
(function() {
if(document.documentElement.className != 'cQ') {
console.log('not our frame');
return;
}
function init() {
if(window.parent == null) {
console.log(typeof window.parent);
console.log(document.documentElement.className);
window.setTimeout(init, 1000);
return;
}
console.log('Found the parent');
}
init();
})();
source
share