how to dynamically load a script library ?

M

Martin Honnen

I want to dynamically include a .js file i.e do something like that :
is it possible with internet explorer 6 ?

Yes:
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'whatever.js';
document.getElementsByTagName('head')[0].appendChild(script);

But loading of the script happens asynchronously so don't try to call
functions directly after the appendChild call.

And while that approach works with IE 6 (and back to IE 5 I think), with
new Mozilla versions and with latest Opera 8, browsers had difficulties
implementing that so there are old Mozilla versions and early Opera 7
versions where it does not work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top