spacer

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

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

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

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 30, 1999
Revised: Nov 30, 1999

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