Created
June 26, 2014 04:28
-
-
Save marcelduran/7512bbcebdf08f00e476 to your computer and use it in GitHub Desktop.
fif.io
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<script>foo = 'iframe'</script> | |
</head> | |
<body> | |
<iframe src="index.html"></iframe> | |
</body> | |
</html> |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<script>foo = 'index'</script> | |
<script src="jquery.min.js"></script> | |
</head> | |
<body> | |
<div id="msg"></div> | |
<script> | |
(function(url) { | |
var dom, doc, where, iframe = document.createElement('iframe'); | |
iframe.src = 'javascript:false'; | |
(iframe.frameElement || iframe).style.cssText = 'width:0;height:0;border:0'; | |
where = document.getElementsByTagName('script'); | |
where = where[where.length - 1]; | |
where.parentNode.insertBefore(iframe, where); | |
try { | |
doc = iframe.contentWindow.document; | |
} catch(e) { | |
dom = document.domain; | |
iframe.src = 'javascript:var d=document.open();d.domain="' + dom + '";void(0)'; | |
doc = iframe.contentWindow.document; | |
} | |
doc.open()._l = function() { | |
var js = this.createElement('script'); | |
if (dom) this.domain = dom; | |
js.id = 'js-iframe-async'; | |
js.src = url; | |
this.body.appendChild(js); | |
}; | |
doc.write('<body onload="document._l()">'); | |
doc.close(); | |
})('script.js'); | |
</script> | |
<!--script src="script.js"></script--> | |
</body> | |
</html> |
This file contains hidden or 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
foo = 'script'; | |
(function() { | |
function wrapped(window, document, iwin, idoc) { | |
with (window) { | |
console.log(this.foo); | |
document.getElementById('msg').innerHTML = $().jquery; | |
} | |
} | |
(window.parent !== window && document.getElementById('js-iframe-async')) ? | |
wrapped.call(parent.window, parent.window, parent.document, window, document) : | |
wrapped.call(window, window, document); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment