Articles | Source Files |  back 

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 possibilities, 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:

fortune = new Array(59);
fortune[0] = "<center>The goal of Computer Science is to build
something that will last at least until we've finished building it.";
fortune[1] = "<center>The <I>first</I> deadly sin is to code 
before you think.";
fortune[2] = "<center>The <I>second</I> deadly sin is to assume 
the user has all the knowledge the software writer has.";
fortune[3] = "<center>The <I>third</I> deadly sin is not to 
write proper documentation.";
fortune[4] = "<center>The <I>fourth</I> deadly sin is to ignore 
language standards.";
fortune[5] = "<center>The <I>fifth</I> deadly sin is to treat error 
diagnosis as an afterthought.";
fortune[6] = "<center>The <I>sixth</I> deadly sin is to equate the 
unlikely with the impossible.";
...

...
fortune[43] = "<center>There are two ways to write error-free programs.
  Only the third one works.";
var now=new Date();document.write("<hr><font size=-1>
",fortune[now.getSeconds()%43],"</font>");

Whereas cookie.htm can actually contain HTML as well as JavaScript:

<html>
<body onLoad="window.setTimeout('RefreshScreen()',10000)">
<script language="JavaScript"><!--
function RefreshScreen() { window.location.href = self.location.href; }

fortune = new Array(59);
fortune[0] = "<center>The goal of Computer Science is to build something 
that will last at least until we've finished building it.";
fortune[1] = "<center>The <I>first<\/I> deadly sin is to code 
before you think.";
fortune[2] = "<center>The <I>second<\/I> deadly sin is to assume the user 
has all the knowledge the software writer has.";
fortune[3] = "<center>The <I>third<\/I> deadly sin is not to write proper 
documentation.";
fortune[4] = "<center>The <I>fourth<\/I> deadly sin is to ignore language 
standards.";
fortune[5] = "<center>The <I>fifth<\/I> deadly sin is to treat error 
diagnosis as an afterthought.";
fortune[6] = "<center>The <I>sixth<\/I> deadly sin is to equate the 
unlikely with the impossible.";
...

...
fortune[43] = "<center>There are two ways to write error-free programs.
  Only the third one works.";
var now=new Date();document.write("<hr><font size=-1>
",fortune[now.getSeconds()%43],"<\/font>");
//--></script>
</body>
</html>

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

 

Menu

Home
Articles
FAQ's
Links
Tools
Blog Links
AJAXCoded Blog
CyberCoded.net
CyberCoder
CybersView

Applications

 

Questions, Comments
or Suggestions

Site Search
FAQ Search

AJAX Coded
CAAD @ CyberCoded.net


 


Copyright


Google
WWW CyberCoded.com
Provide Feedback on CyberCoded.com

Copyright © 1996-2008 CyberCoded.com, All Rights Reserved.
CyberCoded.com liability, trademark, document use and software licensing rules apply. Your interactions with this site are in accordance with our public privacy statements.
Website Hosted By: USNX

We recommend USNX for quality ASP Web Hosting