spacer

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

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

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

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