Created
March 12, 2010 10:56
-
-
Save fjakobs/330230 to your computer and use it in GitHub Desktop.
IE script loading bug
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
<?php | |
header("Content-Type: text/javascript"); | |
header("Cache-Control: private, max-age=34560000", TRUE); | |
?> | |
window.SCRIPT_LOADED = true; | |
if (window.BREAK) debugger; |
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 PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<meta name="author" content="Fabian Jakobs"> | |
<script type="text/javascript" charset="utf-8"> | |
var head = document.getElementsByTagName("head")[0]; | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = "cached-script.php"; | |
script.onreadystatechange = function() { | |
if (script.readyState == "loaded" || script.readyState == "complete") | |
{ | |
head.removeChild(script); | |
window.BREAK = true; | |
var script2 = document.createElement("script"); | |
script2.type = "text/javascript"; | |
script2.src = "cached-script.php"; | |
head.appendChild(script2); | |
} | |
}; | |
head.appendChild(script); | |
</script> | |
</head> | |
<body> | |
<h1>This test demonstrates an IE bug.</h1> | |
Under certain circumstances dynamically inserted scripts are executed | |
synchronously. To see this, open this file in IE and enable the debugger. | |
<p> | |
You'll notice that the <code>appendChild</code> is in the call stack! | |
<p> | |
Note that these files have to be served from a web server with PHP support. | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment