Importing scripts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brett Foster

    Importing scripts

    Is there a way to 'include' javascript at runtime?

    I'm targeting most recent browsers in general, but at worst I'm looking
    for IE/Moz solutions.

    Brett
  • Robert

    #2
    Re: Importing scripts

    Yes. This is the include statement:

    <script type="text/javascript" src="debugminco mmon.js"></script>

    The name of the inlude file is specified by the src parameter. You do
    not put a script header in the inluded file. The path is the normal
    html path.

    Robert

    Comment

    • Brett Foster

      #3
      Re: Importing scripts

      Brett Foster wrote:
      [color=blue]
      > Is there a way to 'include' javascript at runtime?
      >
      > I'm targeting most recent browsers in general, but at worst I'm looking
      > for IE/Moz solutions.[/color]

      Hate to reply to my own thread but after even more searching...

      Here's one solution using IFrames and/or adding JS script tags to the dom.



      if( document.create Element && document.childN odes ) {
      var scriptElem = document.create Element('script ');
      scriptElem.setA ttribute('src', 'someNewUrl.js' );
      scriptElem.setA ttribute('type' ,'text/javascript');
      document.getEle mentsByTagName( 'head')[0].appendChild(sc riptElem);
      }

      Well it does work... not so friendly to look at, but it works.

      Brett[color=blue]
      >
      > Brett[/color]

      Comment

      Working...