I think this is what you are looking for.
<body onload="onloadHandler();">
<script type="text/javascript">
function onloadHandler() {
if (document.createElement && document.getElementsByTagName) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = './test.js';
var heads = document.getElementsByTagName('head');
if (heads && heads[0]) {
heads[0].appendChild(script);
}
}
}
function iAmReady(theName) {
if ('undefined' != typeof window[theName]) {
window[theName]();
}
}
function test() {
}
</script>
- test.js
iAmReady('test');
Firefox 2, Safari 3.1.2 Windows, IE 6 Opera 9.52. , .
, . appendChild(), , script, , script .
script, - .