javascript include
what is the exact syntax of a javascript include?
I thought it was:
<script language="javascript" src="../includes/myfile.js"></script>
but that doesn't seem to be working for me
David
[237 byte] By [
dmeikle] at [2007-11-17 15:47:40]

# 1 Re: javascript include
<script type="text/javascript" src="..\/includes\/myFunctions.js"></script>
type attribute is required
language attribute is deprecated
\ indicates that next character is special
Using backslash (\) before slash (/) isn't mandatory, but ensures that every browser parses the url correctly.
Zvona at 2007-11-8 0:12:30 >

# 2 Re: javascript include
To maintain backward compatibility it is best to include both the type attribute and the language attribute.
<script type="text/javascript" language="JavaScript" src="..\/includes\/myFunctions.js"></script>
Some older browsers require that the string "JavaScript" as the value for the language attribute be in Hungarian notation with a capital "J" and a capital "S", otherwise it doesn't recognize the language.
Also note that should you change myFunctions.js, a browser may cache the old version of the file. It is best to have a date stamp as part of the file name, with the date it was last changed:
myFunctions_100202.js
Every time you change the .js file, rename it with that day's date and change the references to that file. If you include this .js file in many places, you can make a server-side include file that just contains the <script></script> tags so you only have to update 1 file when you change the date stamp file name.
If you wish to make a signed script, to expand security privileges for example, you need to create a JAR file that contains the digital signature, and specify that file in the "archive" attribute.
<script archive="myArchive.jar" type="text/javascript" language="JavaScript" src="..\/includes\/myFunctions_100202.js"></script>