Skip to content

Instantly share code, notes, and snippets.

@vmysla
vmysla / frameless-querySelectorAll.js
Last active August 29, 2015 14:27
Frameless document.querySelectorAll shim
/// @usage document.querySelectorAll('body');
/// @returns array of matched elements from document and his IFRAMEs (CORS)
document.querySelectorAll = function(){
var result = [].slice.call( HTMLDocument.prototype.querySelectorAll.apply(document, arguments ) );
for(var i=0; i< frames.length; i++){
try {
var doc = frames[i].document;
result = result.concat( [].slice.call( doc.querySelectorAll.apply(doc, arguments) ) );
} catch(e){}
}