spacer

home / experts / diner / scriptsrc
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

DHTML Diner Logo

Loading External JS Files for DHTML Browsers



The Navigator 3 Problem

As mentioned, Navigator 3 was the first, and at that time, only browser to recognize the SRC= attribute of <SCRIPT>. Somehow, the eventuality of other browsers (or even newer versions of their own browser) supporting the attribute, and using it for scripts written in languages other than Javascript1.0 or JavaScript1.1 escaped Netscape.

Navigator 3 attempts to execute any external file specified by SRC=, whether it supports the language specified by LANGUAGE= or not!

If the filename has a .js extension, it is executed as JavaScript. If not, it may be loaded as a text file and displayed, or may even crash the browser!

For example, the following are all executed as JavaScript files by Netscape 3:

<SCRIPT LANGUAGE="JScript" SRC="extJscript.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="extJS12.js"></SCRIPT>
<SCRIPT LANGUAGE="Sanskrit" SRC="extSanskrit.js"></SCRIPT>

This file is loaded and displayed as text (or may terminate browser session):

<SCRIPT LANGUAGE="Sanskrit" SRC="extSanskrit.sk"></SCRIPT>

The Solution

All external script files not meant for Navigator 3, but included in a web page accessible by Navigator 3, should be loaded indirectly. That is, Navigator 3 must be excluded from reading the tag containing the SRC attribute.

Navigator 3 should not see any tags with the SRC pointing to JScript, VBScript or JavaScript 1.2+ external files.

If the SRC is omitted, Navigator 3 will correctly ignore any scripts with an incompatible LANGUAGE attribute value.

Therefore, we exclude Navigator 3 by using LANGUAGE="JavaScript1.2" in a <SCRIPT> tag, without an SRC, and then dynamically insert another <SCRIPT>, with an SRC into the page:

<SCRIPT LANGUAGE="JavaScript1.2">
<!--
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='myDHTMLSource.js'></SCRIPT>");
//-->
</SCRIPT>

Now, all version 4, DHTML-enabled, browsers will load and execute the external script.

Well, almost all. Now, Explorer 4 for the Macintosh has a problem.



Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

All Rights Reserved. Legal Notices.
Created: Nov 2, 1999
Revised: Nov 2, 1999

URL: http://www.webreference.com/dhtml/diner/scriptsrc/scriptsrc2.html