how to dynamically load a script library ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • philippe.laplanche@horus-si.com

    how to dynamically load a script library ?

    Hello

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

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

    is it possible with internet explorer 6 ?

    Thanks in advance

    Philippe Laplanche

  • Martin Honnen

    #2
    Re: how to dynamically load a script library ?



    philippe.laplan che@horus-si.com wrote:

    [color=blue]
    > I want to dynamically include a .js file i.e do something like that :[/color]
    [color=blue]
    > is it possible with internet explorer 6 ?[/color]

    Yes:
    var script = document.create Element('script ');
    script.type = 'text/javascript';
    script.src = 'whatever.js';
    document.getEle mentsByTagName( 'head')[0].appendChild(sc ript);

    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.


    --

    Martin Honnen

    Comment

    Working...