Created
April 22, 2013 23:16
-
-
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?
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
| <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> |
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
| <h1>Parent</h1> | |
| <a id="link1" href="#">Click</a> | |
| <a id="link2" href="#">Click</a> | |
| <iframe src="child.html"> | |
| </iframe> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanation here and here.