PDA

View Full Version : JavaScript and Include Menu error


dclao
07-09-2004, 12:25 PM
I developed a drop down menu that is attached to the top of each page on my website (under the main site's menu). It works on my development laptop but doesn't work when posted on the server. I'm told that there aren't any differences between them and how they handle my code...so it must be my code.

Here is the main page: http://jitc.fhu.disa.mil/jdep_jitc/index.html

Here is the error (from IE):
Line: 10
Char: 2
Error: 'null' is null or not an object
Code: 0

Here's my html:
<HTML>
<HEAD>
<TITLE>JITC</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="/include/main/jitc.css">
</HEAD>
<BODY TOPMARGIN=0 LEFTMARGIN=0 BGCOLOR="#FFFFFF">
<!--#include virtual="/include/main/jitc_header.html" -->
<script type="text/javascript" src="include/popup_menu.js"></script>
<script type="text/javascript" src="include/init_img_rotation.js"></script>

<link rel="stylesheet" href="include/popup_menu.css">
<link rel="stylesheet" HREF="include/jdep.css">

<BODY onload="initImgRotation(); mbSet('mb2', 'mbh');">

<TABLE width="100%" cellspacing="0" cellpadding="0" border="0">
<TR>
<TD WIDTH="700" HEIGHT="125" COLSPAN="2" ALIGN="left" VALIGN="top" BACKGROUND="images/jdep_index_title.jpg">
<!--#include virtual="menu.html" -->
</TD>
</TR>
<TR>
<TD width="300" valign="middle" align="center"><img name="img1" src="images/rotate_blank.jpg" alt="JDEP Images"></TD>
<TD width="400"><DIV ALIGN="JUSTIFY">BLAH... BLAH... BLAH...</DIV></SPAN></TD> </TR>
</TABLE>
</body>
<!--#include virtual="/include/main/jitc_footer.html" -->
</BODY>
</HTML>

The error appears to be happening with:
<TD WIDTH="700" HEIGHT="125" COLSPAN="2" ALIGN="left" VALIGN="top" BACKGROUND="images/jdep_index_title.jpg">
<!--#include virtual="menu.html" -->
</TD>

My menu basically looks like:
<ul id="mb2">
<li><a href="#"><center>General Info.</center></a>
<ul>
<li><a href="mission.html">Mission</a></li>
<li><a href="pocs.html">Contact</a></li>
</ul>
</li>
<li><a href="index.html"><center>Home</center></a></li>
</ul>

My JavaScript is attached.

Any help you can give me is GREATLY appreciated.

agent002
07-09-2004, 12:57 PM
The file you attached is not the only one that belong to the menu script; there is also a 29 kB JavaScript file... Frankly, I'm really not fond of hunting down an error from such a biggie script, especially not considering you can do the same with a completely CSS-based dropdown (http://www.alistapart.com/articles/dropdowns/) (it uses about 20 lines of JavaScript though, due to IE's poor standards support).

dclao
07-09-2004, 01:08 PM
The other file is part of the "required" header and footer for the website and isn't causing the problem; that's why I didn't include it. The problem is coming from my code...some how.

If there is a better way to do this I would love to know because it has been a pain getting it to work and now it won't work the same way in two different places.

dclao
07-12-2004, 05:06 PM
Thanks for the info on Suckerfish Dropdowns. Paging through the comments I found a better solution to the menu at:

http://www.brainjar.com/dhtml/menubar/demo3.html

It took advantage of the Suckerfish Dropdowns but also enabled me to add additional levels within the menu - easily!!

Also --- the problem I encountered with the menu wasn't the Javascript at all. It ended up being the <!--#include virtual=menu.html --> for some reason the index file couldn't find the menu file. I used <!--#include file=menu.html --> and it worked great!
:D