Skip to content

Instantly share code, notes, and snippets.

@xyqfer
Created September 28, 2013 07:20
Show Gist options
  • Save xyqfer/6739468 to your computer and use it in GitHub Desktop.
Save xyqfer/6739468 to your computer and use it in GitHub Desktop.
动态加载Javascript文件
var script = document.createElement("script");
if (script.readyState) {
script.onreadystatechange = function() {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;
alert("ie");
}
}
} else {
script.onload = function() {
alert("nice");
}
}
script.src = "test.js";
document.getElementsByTagName("head")[0].appendChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment