Hiermenus Go Forth, IX - DHTML Lab | 3 | WebReference

Hiermenus Go Forth, IX - DHTML Lab | 3

Logo

Hiermenus Go Forth, IX:
Version 4.0.2 - The Complete Script (Full-Window)



Watch your HTML!
(and keep an eye on your editor's HTML while you're at it)

The stripped-down HTML examples on the previous page make the source of the problem obvious. For the dozens of readers who wrote in to file an IE bug, it was not so obvious because of the complexity of their pages.

Many noted that the problem disappeared if the <SCRIPT> tag was placed immediately after the BODY tag. This is true, but it does not relate to the origin of the problem. It works around the problem.

IE will display the error message when previous HTML tags have not been properly resolved and it encounters invalid tag nesting.

Invalid HTML is usually overlooked and browsers makes adjustments for it. In our case, however, the problem is too huge to be adjusted. The browser gives up (aborts) and fires the error.

Version 4 for full-window builds the menu elements and inserts them into the page as the page loads. They are created where the <SCRIPT> tag is inserted. With that in mind, let's look at the error-generating examples again:

<BODY>
...some page HTML...
<BLOCKQUOTE>...some more HTML...
<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>
</BODY>
</HTML>

<-- the complex menu elements are
    placed within a BLOCKQUOTE!
<BODY>
...some page HTML...
<BLOCKQUOTE>...some more HTML...
<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>
</BLOCKQUOTE>
</BODY>
</HTML>

<-- the complex menu elements are again
    placed within a BLOCKQUOTE!
<BODY>
...some page HTML...
<A HREF="defaultlink.html"
   onMouseOver="popUp('elMenu1',event)"
   onMouseOut="popDown('elMenu1',event)">
       Experts<A/>
<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>
</BODY>
</HTML>

<-- typo in closing A tag causes the
    the tag to be ignored and 
    the menu elements to be placed within
    a link!

Here are the reasons the other examples do not generate errors:

<BODY>
<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>
...some page HTML...
<BLOCKQUOTE>...some more HTML...
</BODY>
</HTML>

<-- the menu elements are
    created before invalid HTML
<BODY>
...some page HTML...
<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>
<A HREF="defaultlink.html"
   onMouseOver="popUp('elMenu1',event)"
   onMouseOut="popDown('elMenu1',event)">
       Experts<A/>
</BODY>
</HTML>

<-- the menu elements are
    created before the typo
    and the resulting poor HTML
<BODY>
...some page HTML...
<BLOCKQUOTE>...some more HTML...</BLOCKQUOTE>
<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>
</BODY>
</HTML>

<-- HTML resolved with closing BLOCKQUOTE
    tag before the menus are created
<BODY>
...some page HTML...
<A HREF="defaultlink.html"
   onMouseOver="popUp('elMenu1',event)"
   onMouseOut="popDown('elMenu1',event)">
       Experts</A>
<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>
</BODY>
</HTML>

<-- HTML resolved with correctly
    entered closing A tag
    before the menus are created

Therefore, please watch your HTML. Resolve all open tags before the <SCRIPT> tag is included. This is only good coding practice. As we move closer to standards, and pages adhere to strict DTD's, the sloppiness we have all overlooked in the past will come back to haunt us.

But, it is not just individual authors who must practise good coding. They should watch the commercial editing tools as well. One reader who had the error occur sent in this code, created using Front Page:

<BODY BACKGROUND="../_themes/blank/blbkgnd.gif"
      BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#999999"
      VLINK="#990000" ALINK="#666666">
      <!--mstheme-->
      <FONT FACE="Arial, Arial, Helvetica">
          Hello
          <SCRIPT LANGUAGE="JavaScript1.2"
                  SRC="HM_Loader.js"
                  TYPE='text/javascript'></SCRIPT>
          <!--mstheme-->
     </FONT>
</BODY>
</HTML>

Front Page, and all other editors, are not aware of the contents of the external script. For all they know the script might contain this one line:

document.write("hello world");

If it did, then the FONT tag would apply to the "hello world" text and the SCRIPT's inclusion at this point would not be invalid.

We know, however, that the SCRIPT creates the menu elements which should not be enclosed in a FONT tag! We, must therefore, double-check all HTML in our page, resolving all tags before the SCRIPT tag is included.

On the next page, the fixes included in Version 4.0.2.


Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: Jan 09, 2001
Revised: Jan 09, 2001

URL: https://www.webreference.com/dhtml/column45/3.html