Skip to content

Instantly share code, notes, and snippets.

@jfirebaugh
Created April 22, 2013 23:16
Show Gist options
  • Select an option

  • Save jfirebaugh/5439412 to your computer and use it in GitHub Desktop.

Select an option

Save jfirebaugh/5439412 to your computer and use it in GitHub Desktop.
Why does the first link cause iframe-in-iframe, but not the second link?
<h2>Child</h2>
<script>
parent.document.getElementById("link1").onclick = function() {
location.replace("#foo");
return false;
};
parent.document.getElementById("link2").onclick = function() {
setTimeout(function() {
location.replace("#foo");
}, 0);
return false;
};
</script>
<h1>Parent</h1>
<a id="link1" href="#">Click</a>
<a id="link2" href="#">Click</a>
<iframe src="child.html">
</iframe>
@jfirebaugh
Copy link
Author

Explanation here and here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment