Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / June 2005



Tip: Looking for answers? Try searching our database.

how to dynamically load a script library ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
philippe.laplanche@horus-si.com - 30 Jun 2005 18:15 GMT
Hello

I want to dynamically include a .js file i.e do something like that :

load_js_file("http://domain.com/myfile.js");

is it possible with internet explorer 6 ?

Thanks in advance

Philippe Laplanche
Martin Honnen - 30 Jun 2005 18:24 GMT
> 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.

Signature

    Martin Honnen
    http://JavaScript.FAQTs.com/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.