spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column27
Developer News
Eclipse Helios Update Brings New PHP Tools
Internet Explorer 9 Ups Standards Support
JBoss Portal 5 Release Easier to Use

Logo

Dynamic Headline Fader, Version 3.0
Loading the external scripts with ASP


The Problem

When loading an Active Server Page (ASP) page with the Fader script, the ASP interpreter displays an error message regarding "improperly nested SCRIPT tags."

Once again, the problem is caused by our conditional script-loading statements, which were:

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

When ASP build the page, they render the statements literally, creating illegal HTML:

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
   <SCRIPT LANGUAGE="JavaScript1.2" SRC="news.js" TYPE="text/javascript"></SCRIPT>
   <SCRIPT LANGUAGE="JavaScript1.2" SRC="fader.js" TYPE="text/javascript"></SCRIPT>
</SCRIPT>

With our new, old-Navigator-compatible version, ASP would try to render:

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
   <SCRIPT LANGUAGE="JavaScript1.2" SRC="news.js" TYPE="text/javascript"></SCRIPT>
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
   <SCRIPT LANGUAGE="JavaScript1.2" SRC="fader.js" TYPE="text/javascript"></SCRIPT>
</SCRIPT>

The Solution

The nested SCRIPT tag needs to be hidden from the ASP engine. This is accomplished by breaking the document.write() strings into 3 smaller strings, so that "SCRIPT" is never encountered as a complete word:

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

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

Done, with Fader Version 3.0. If you've lost track of all the browser versions our script is now compatible with, check out the compatibility table on the next page. After that, we'll repeat the complete code.


Produced by Peter Belesis and

webref The latest from WebReference.com Browse >
Flashmaps' DynamicLocator: Interactive Maps for Small Areas · Flashmaps' AreaSelector: Interactive Maps for Wide Areas · The DB Mapper: Interactive Street-level Maps of U.S. and Canada
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags

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

URL: http://www.webreference.com/dhtml/column27/fade3asp.html