Skip to content

Instantly share code, notes, and snippets.

@rauschma
Created August 28, 2012 23:29
Show Gist options
  • Save rauschma/3505283 to your computer and use it in GitHub Desktop.
Save rauschma/3505283 to your computer and use it in GitHub Desktop.
iframe test
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>instanceof test</title>
<script>
// test() is called from the iframe
function test(arr) {
var iframeWin = frames[0];
console.log(arr instanceof Array); // false
console.log(arr instanceof iframeWin.Array); // true
console.log(Array.isArray(arr)); // true
}
window.onload = function () {
var iframeWin = frames[0];
iframeWin.document.write("<script>window.parent.test([])</"+"script>");
}
</script>
</head>
<body>
<iframe></iframe>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment