Include file

In a lot of languages you have a syntax like
#include
require "file"
@import url('style.css');


Is there a function like that in JavaSCript?
E.g. I have two files with the same functions, but different implementations. Is it possible to do something like:
[code]

// Some code that checks browser and
// sets isMSIE to true if IE else sets isMSIE to false
// Anyway, you get the point, I guess

// Check browser
if (isMSIE) // Load functions for explorer
include('explorer.js');
else // Load functions for other browser
include('notmsie.js');


[/code]
the onLoadFunction is defined in both of the files, so the appropriate function is called when the page is loaded.
Any help would be greatly appreciated.

Comments

  • [b][red]This message was edited by the Darius at 2002-5-19 14:56:18[/red][/b][hr]
    : In a lot of languages you have a syntax like
    : #include
    : require "file"
    : @import url('style.css');
    :
    :
    : Is there a function like that in JavaSCript?
    : E.g. I have two files with the same functions, but different implementations. Is it possible to do something like:
    : [code]
    :
    : // Some code that checks browser and
    : // sets isMSIE to true if IE else sets isMSIE to false
    : // Anyway, you get the point, I guess
    :
    : // Check browser
    : if (isMSIE) // Load functions for explorer
    : include('explorer.js');
    : else // Load functions for other browser
    : include('notmsie.js');
    :
    :
    : [/code]
    : the onLoadFunction is defined in both of the files, so the appropriate function is called when the page is loaded.
    : Any help would be greatly appreciated.
    :

    You do realize you answered your own question.

    if(isMSIE) document.write("");
    else document.write("");

    The reason I broke the tags apart is because I didn't want the parser to think that the embedded in the string was the end of the block.

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion