My goal is to have an external js file loading a set of js files. In this case, for starters, just one subsequent external js, js2.js.
loader.html - to load all the subsequent js files.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>JsLoader</title>
<script src='js1.js' type='text/javascript' /></script>
</head>
<body>
<input type="button" onClick="f1()" value="Load" />
</body>
</html>
js1.js - External js file 1
function f1(){
var NewScript=document.createElement('script')
NewScript.src="js2.js"
document.body.appendChild(NewScript);
f2();
}
j2.js- External js file 2
function f2(){
alert('I told you I can get here!')
}
Files:
loader.html |
js1.js |
js2.js |
No comments:
Post a Comment