DHTML Lab: HierMenus CENTRAL: Version 3.x FAQ #2 - dhtmlab.com | WebReference

DHTML Lab: HierMenus CENTRAL: Version 3.x FAQ #2 - dhtmlab.com

Frequently Asked Question #2

Entered: Dec 29, 1998


I am attempting to use the menus with Active Server Pages, but ASP displays an error message regarding "improperly nested SCRIPT tags." Why does this happen, and how can I avoid it?

The source of the problem is this group of statements:

<SCRIPT LANGUAGE="JavaScript1.2">
<!--
if (isMenu) {
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='hierArrays.js'><\/SCRIPT>");
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='hierMenus.js'><\/SCRIPT>");
}
//-->
</SCRIPT>



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

<SCRIPT LANGUAGE="JavaScript1.2">
   <SCRIPT LANGUAGE='JavaScript1.2' SRC='hierArrays.js'></SCRIPT>
   <SCRIPT LANGUAGE='JavaScript1.2' SRC='hierMenus.js'></SCRIPT>
</SCRIPT>


There are 2 solutions:

1. The document.write() method is used only to avoid the Netscape 3 bug related to the SRC= attribute. If the menus are being used in a menu-enabled-browser-only environment (eg. intranet) then you can omit the dynamic SCRIPT tag generation and simply use:

<SCRIPT LANGUAGE='JavaScript1.2' SRC='hierArrays.js'></SCRIPT>
<SCRIPT LANGUAGE='JavaScript1.2' SRC='hierMenus.js'></SCRIPT>


2. You can break the document.write() string into 3 smaller strings, so that "SCRIPT" is never encountered as a complete word:

<SCRIPT LANGUAGE="JavaScript1.2">
<!--
if (isMenu) {
document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='hierArrays.js'><\/SCR" + "IPT>");
document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='hierMenus.js'><\/SCR" + "IPT>");
}
//-->
</SCRIPT>


Since these statements fix the ASP problem but do not affect non-ASP menus, they may be included as standard in a future version of the menu script.



Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: Dec 29, 1998
Revised: June 26, 2001

URL: https://www.webreference.com/dhtml/hiermenus/version3/faq/faq2.html

Justtechjobs.comFind a programming school near you






Online Campus Both