Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Related items

A JavaScript Web-Ring

Internet Explorer version 3.02 and SRC files

Source Files

You are here: irt.org | Articles | JavaScript | Source | Source Files [ previous next ]

Published on: Sunday 9th March 1997 By: Martin Webb

The following is taken from the Netscape Navigator 3.0 JavaScript Guide:

JavaScript statements within a <SCRIPT> tag with a SRC attribute are ignored unless the inclusion has an error. For example, you might want to put the following statement between the <SCRIPT SRC="..."> and </SCRIPT> statements:

document.write("Included JS file not found")

The SRC attribute can specify any URL, relative or absolute. For example:

<SCRIPT SRC="http://home.netscape.com/functions/jsfuncs.js">

External JavaScript files cannot contain any HTML tags: they must contain only JavaScript statements and function definitions.

External JavaScript files should have the file name suffix .js, and the server must map the .js suffix to the MIME type "application/x-JavaScript", which the server sends back in the HTTP header. To map the suffix to the MIME type, add the following line to the mime.types file in the server's config directory, and then restart the server.

type=application/x-JavaScript exts=js

If the server does not map the .js filename suffix to "application/x-JavaScript" MIME type, Navigator will not load the JavaScript file specified by the SRC attribute properly.

Note This requirement does not apply if you are using local files.

Internet Explorer 3.0 does not support this feature of JavaScript, however Internet Explorer does support floating frames which can reference another HTML file using the following syntax.

<iframe
   align=left|center|right|top|bottom
   frameborder=1|0
   height=height
   marginheight=height
   marginwidth=width
   name=name
   scrolling=yes|no
   src=address
   width=width>
<\/iframe>

Netscape does not support floating frames (yet) - which leads to interesting posibilities, for example:

<script language="JavaScript"><!--
if (navigator.appVersion.indexOf('MSIE 3') != -1) {
  document.write(
    '<iframe frameborder="0" width="100%" height="100" ' +
    'marginheight="5" marginwidth="5" name="cookie" ' +
    'scrolling="no" src="cookie.htm"><\/iframe>'
  );
}
else {
  document.write(
    '<script language="JavaScript" src="cookie.js"></script>'
  );
}
//--></script>

The above code, is more complicated than I originally intended. However, certain versions of MSIE 3.02 support JavaScript *.js source files (although MSIE 3.02 does have certain limitations - see the following article for further information Internet Explorer 3.02 and SRC files.

Since the introduction of MSIE 4 - there is now full support for JavaScript *.js source files. So the above code loads the cookie.htm file for MSIE 3, and for the remainder it loads the cookie.js file.

cookie.js must only contain JavaScript, whereas cookie.htm can actually contain HTML as well as JavaScript.

Depending on which browser you are using you will see below either the output from cookie.js or cookie.htm:

Related items

A JavaScript Web-Ring

Internet Explorer version 3.02 and SRC files

Feedback on 'Source Files'

©2018 Martin Webb