spacer

home / experts / diner / scriptsrc
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

DHTML Diner Logo

Loading External JS Files for DHTML Browsers



The Explorer 4 Macintosh Problem

If we try to load an external file with the script developed on the previous page, Explorer 4 (both 4.01 and 4.5) will give us this error:

What Explorer 4 Macintosh objects to is the dynamically written closing script tag (</SCRIPT>). It sees it as a literal closing tag, complementary to the first <SCRIPT> tag. In other words, it parses the tags and script as if they were written like this:

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

The document.write() method, above, attempts to write an unterminated string, so the error is generated.

The Solution

Explorer 4 for the Macintosh must be made aware that the dynamically written "</SCRIPT>" is not to be taken literally, but be included as part of the string to be written to the page.

We simply escape the forward slash (/), with a backslash (\), so that IE4Mac recognizes it as part of the string:

<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, they will, but it won't be HTML 4 compatible. Since more and more webmasters insist on standards-compliance, we should make one addition to the tags.



Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

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

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