This message was edited by the Darius at 2002-5-19 14:56:18
: In a lot of languages you have a syntax like
: #include <file>
: require "file"
: @import url('style.css');
: <SCRIPT SRC="explorer.js"></SCRIPT>
:
: 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:
:
: <SCRIPT>
: // 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');
: </SCRIPT>
: <BODY onLoad="onLoadFunction();">
:
: 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("<SCR"+"IPT SRC=explorer.js></SCR"+"IPT>");
else document.write("<SCR"+"IPT SRC=notmsie.js></SCR"+"IPT>");
The reason I broke the <SCRIPT></SCRIPT> tags apart is because I didn't want the parser to think that the </SCRIPT> embedded in the string was the end of the <SCRIPT> block.
"We can't do nothing and think someone else will make it right."
-Kyoto Now, Bad Religion