Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Created October 30, 2015 13:10
Show Gist options
  • Save benfoxall/e5bc132ee585074b1366 to your computer and use it in GitHub Desktop.
Save benfoxall/e5bc132ee585074b1366 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>iframe inject test</title>
</head>
<body>
<script type="text/javascript">
var f = document.createElement('iframe');
f.src = 'data:text/html;charset=utf-8,%3Ch1%3Ehello%3C%2Fh1%3E';
document.body.appendChild(f);
var bs = new Blob(['document.write("sub script");document.body.style.background="#ccc"'], {type : 'text/javascript'});
var bsurl = URL.createObjectURL(bs);
var b = new Blob(['<h1>HELLO</h1><script>document.write("ok")<','/script><script src="',bsurl,'"><','/script>'], {type : 'text/html'});
var url = URL.createObjectURL(b);
var f = document.createElement('iframe');
f.src = url;
document.body.appendChild(f);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment