(Sorry for the duplicate post - I was going to change the subject
before posting and forgot...)
I'm trying to create script that can dynamically execute script from a
given source and then call a callback function when complete. I have
the following...
function bar() {
alert( 'bar' );
}
function foo() {
var s=document.getE lementById( 'dynamicScriptE lement' );
if( !s ) {
s=document.crea teElement( 'script' );
s.type='text/javascript';
s.id='dynamicSc riptElement';
document.docume ntElement.child Nodes[1].appendChild( s );
}
s.src='test.js' ;
bar();
}
1) Is the script in test.js guaranteed to be executed before bar() is
called?
2) foo() assumes that the <html> element has a <head> and <body> -
presumably that's reasonable, right?
3) Any other comments would be appreciated!
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
before posting and forgot...)
I'm trying to create script that can dynamically execute script from a
given source and then call a callback function when complete. I have
the following...
function bar() {
alert( 'bar' );
}
function foo() {
var s=document.getE lementById( 'dynamicScriptE lement' );
if( !s ) {
s=document.crea teElement( 'script' );
s.type='text/javascript';
s.id='dynamicSc riptElement';
document.docume ntElement.child Nodes[1].appendChild( s );
}
s.src='test.js' ;
bar();
}
1) Is the script in test.js guaranteed to be executed before bar() is
called?
2) foo() assumes that the <html> element has a <head> and <body> -
presumably that's reasonable, right?
3) Any other comments would be appreciated!
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Comment