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

Q5 Why does Netscape show the source of the *.js source file?

You are here: irt.org | FAQ | JavaScript | Source | Q5 [ previous next ]

The server has not been setup to correctly serve *.js source files. 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.

Feedback on 'Q5 Why does Netscape show the source of the *.js source file?'

©2018 Martin Webb