Last active
August 29, 2015 14:20
-
-
Save HomerJSimpson/7538899c43a572a558f3 to your computer and use it in GitHub Desktop.
walk iframes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myFrames = []; | |
function mkLog(name) { | |
return function() { | |
console.log('unloading ' + name); | |
}; | |
} | |
(function walk(d) { | |
var doc = d.contentDocument || d, i, iframes = doc.getElementsByTagName('iframe'); | |
console.log('found ' + iframes.length + ' iframes'); | |
myFrames.push({ doc :doc, frame : d.contentDocument, node : d, id : d.id, name:d.name }); | |
if(d.tagName === "IFRAME") { | |
d.contentWindow.onbeforeunload = mkLog(d.id); | |
} | |
for(i=0;i<iframes.length;++i) { | |
try { | |
walk(iframes[i]); | |
} catch(e) { console.log('skipping'); } | |
} | |
}(document));console.dir(myFrames);"done"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment