In Navigator 3.0 and Internet Explorer 3.0, the <SCRIPT> tag supports a new SRC attribute. The value of this attribute specifies the URL of a file of JavaScript code. It is used like this:
<SCRIPT SRC="../../javascript/util.js"></SCRIPT>
A JavaScript file is just that--pure JavaScript, without <SCRIPT> tags or any other HTML. A JavaScript file typically has a .js extension, and should be exported by a web server with MIME-type "application/x-javascript". This last point is important, and may require special configuration of your web server in order to successfully use JavaScript files in this way.
The behavior of the <SCRIPT> tag with the SRC attribute specified is exactly as if the contents of the specified JavaScript file appeared directly between the <SCRIPT> and </SCRIPT> tags. Any code that does appear between the open and close <SCRIPT> tags will be ignored by browsers that support the SRC attribute (although it would still be executed by browsers, like Navigator 2.0, that do not recognize the tag). Note that the closing </SCRIPT> tag is required even when the SRC attribute is specified and there is no JavaScript between the <SCRIPT> and </SCRIPT> tags.
Since both Navigator 3.0 and Internet Explorer 3.0 both support the SRC attribute, you cannot assume that any browser that understands the SRC tag also understands JavaScript 1.1. Thus it is a good idea to use the LANGUAGE attribute with the SRC attribute:
<SCRIPT LANGUAGE="JavaScript1.1" SRC="../../javascript/util.js"></SCRIPT>
There are a number of advantages to using the SRC tag:
file: /Techref/language/java/script/definitive/ch10_02.htm, 7KB, , updated: 2019/10/14 15:00, local time: 2024/11/30 02:23,
3.15.239.50:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/Techref/language/java/script/definitive/ch10_02.htm"> [Chapter 10] 10.2 Including JavaScript Files</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.