By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,629 Members | 1,793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,629 IT Pros & Developers. It's quick & easy.

asdf

P: n/a
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.getElementById( 'dynamicScriptElement' );
if( !s ) {
s=document.createElement( 'script' );
s.type='text/javascript';
s.id='dynamicScriptElement';
document.documentElement.childNodes[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)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Christopher Benson-Manica <at***@nospam.cyberspace.org> spoke thus:
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...


I screwed up the subject of this post and so I have reposted with a more
appropriate subject. Sorry.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.