spacer

home / experts / diner / scriptsrc
Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source
DHTML Diner Logo

Loading External JS Files for DHTML Browsers



The Official Documentation

When Netscape Navigator 3 was released with the JavaScript 1.1 engine, one major improvement was the introduction of the SRC= attribute for the <SCRIPT> tag.

At the time, the Release Notes described the new attribute in this way:

SRC attribute: The <SCRIPT> tag now has an additional attribute that allows a JavaScript file to be specified as the JavaScript source (rather than embedding the JavaScript in the HTML). Attributes within the SCRIPT tag can now be specified as follows:

<SCRIPT LANGUAGE="JavaScript" SRC="mySource.js">

where mySource.js is the URL (relative or full address) of the JavaScript source code file.

The SRC attribute specifies the scripting language by using the .js suffix. The suffix must be mapped by the web server to the MIME type "application/x-javascript"

. . .

from the Navigator 3.0 Release Notes

With Navigator 4, we had the introduction of DHTML and JavaScript 1.2. We could, therefore, specify DHTML-specific scripts by using a value of JavaScript1.2 value for the LANGUAGE= attribute:

<SCRIPT LANGUAGE="JavaScript1.2">

Older browsers would not recognize the attribute value and ignore the script.

Explorer 4, while not being 100% compatible with JavaScript 1.2, also recognized the JavaScript1.2 value. We could therefore safely include scripts to be read only by DHTML browsers, if we specified JavaScript1.2 as the LANGUAGE.

It follows that external scripts can be conditionally loaded for DHTML browsers by using this syntax:

<SCRIPT LANGUAGE="JavaScript1.2" SRC="myDHTMLSource.js">

The DHTML Lab Way

You will have noticed that here at DHTML Lab, we load external JS files for DHTML browsers with this syntax:

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

If you have read all our columns, you will be aware of the reasons for this awkward and, seemingly, overly verbose syntax.

If not, this short article will explain why we use our syntax and not the documented syntax. Along the way, we'll also explore several browser bugs and quirks.

First, we need to look at a problem with Navigator 3.



Produced by Peter Belesis and

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

webref The latest from WebReference.com Browse >
Working with the DOM Stylesheets Collection · Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Combine BottomCount() with Other MDX Functions to Add Sophistication · Creating a Daemon with Python · The Coming Voice-over-WiMAX Revolution

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

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