Solved

menuLayer is null or not an object

Posted on 2006-06-13
11
549 Views
Last Modified: 2009-07-29
Good morning! I have a webpage which is "done but with errors on the page". The error says,

Line 530
Char 3
menuLayer is null or not an object

 I'm not sure what that means, exactly. Also, if I view>source, I don't appear to have 530 lines on that page.

 Thanks!
0
Comment
Question by:mel200
  • 6
  • 5
11 Comments
 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16895220


it includes the javascript lines in .js files....   if you paste the .js code in your page between script tags you can see.  or use the javascript console in FF.
0
 

Author Comment

by:mel200
ID: 16895521
hi-here is the javascript on that page; do you see anything bad? I'm sorry, I am really not good at javascript, although I hope to take a course soon!!

<script language="JavaScript" type="text/javascript">
<!--
      function swapImgRestore() { //v3.0
        var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
      }

      function preloadImages() { //v3.0
        var d=document; if(d.images){ if(!d.p) d.p=new Array();
          var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
          if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
      }

      function findObj(n, d) { //v3.0
        var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
          d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
        if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
      }

      function swapImage() { //v3.0
        var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
         if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
      }
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
      function MM_preloadImages() { //v3.0
        var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
          var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
          if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
      }
      
      function MM_swapImgRestore() { //v3.0
        var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
      }
      
      function MM_findObj(n, d) { //v4.0
        var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
          d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
        if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
        if(!x && document.getElementById) x=document.getElementById(n); return x;
      }
      
      function MM_swapImage() { //v3.0
        var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
         if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
      }
//-->
</script>


<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
function newImage(arg) {
      if (document.images) {
            rslt = new Image();
            rslt.src = arg;
            return rslt;
      }
}

function changeImages() {
      if (document.images && (preloadFlag == true)) {
            for (var i=0; i<changeImages.arguments.length; i+=2) {
                  document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
            }
      }
}

var preloadFlag = false;

function preloadImages() {
      if (document.images) {
            home_over = newImage("#request.imagesroot#/nav_images/homerol.gif");
            preloadFlag = true;
      }
}
// -->
</SCRIPT>



      <SCRIPT LANGUAGE="JavaScript" type="text/javascript">
      <!--
      
      
      function fwLoadMenus()
     {
      if (window.fw_menu_0) return;
      
      
      window.fw_menu_2 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"#000000","#FFFFFF","#F5F5EB","#FF5416",7); //F4F217 17B3F4
    fw_menu_2.addMenuItem("Spring Menu","location='/catalog/index.cfm?fuseaction=cust_catalog&product_id=384&Cat_sort=1&rest_cat=0&pageRef=current_month_cust'");
        fw_menu_2.addMenuItem("Summer Menu","location='http://www.mysite/info_pages/index.cfm?fuseaction=all&parent_id=18'");
          fw_menu_2.addMenuItem("Meal Packages","location='http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=85'");
         fw_menu_2.hideOnMouseOut=true;
        
           window.fw_menu_3 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"#000000","#FFFFFF","#F5F5EB","#FF5416",7); //F4F217 17B3F4
    fw_menu_3.addMenuItem("Nutrition ","location='http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=31'");
        fw_menu_3.addMenuItem("Thawing & Reheating","location='http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=33'");
         fw_menu_3.hideOnMouseOut=true;
        
          window.fw_menu_4 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"#000000","#FFFFFF","#F5F5EB","#FF5416",7); //F4F217 17B3F4
        fw_menu_4.addMenuItem("Newsletter","location='http://www.mysite.com/customers/index.cfm?fuseaction=newsletter'");
         fw_menu_4.hideOnMouseOut=true;
        
            window.fw_menu_5 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"#000000","#FFFFFF","#F5F5EB","#FF5416",7); //F4F217 17B3F4
     
      fw_menu_5.addMenuItem("Corporate Presentation","location='http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=78'");
fw_menu_5.addMenuItem("Fundraising","location='http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=79'");
fw_menu_5.addMenuItem("Our Staff","location='http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=36'");
fw_menu_5.addMenuItem("Newsletter","location='http://www.mysite.com/customers/index.cfm?fuseaction=newsletter'")
fw_menu_5.addMenuItem("Terms and Conditions","location='http://www.mysite.com.com/info_pages/index.cfm?fuseaction=all&parent_id=82'");
         fw_menu_5.hideOnMouseOut=true;
        
      
        
 writeMenus();
    }
      
      
      
      // -->
      </SCRIPT>



<body bgcolor="#ffffff" onLoad="MM_preloadImages('images/home/this_months_menu_f2.gif','home/to_go_f2.gif','home/cook&amp;carry_f2.gif','home/personal_chef_f2.gif','home/this_months_menu_f2.gif');rotateTopLeft();" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#333300" link="#333300" vlink="#333300" alink="#666600">

<script language="JavaScript" type="text/javascript" src="fw_menu.js"> </script>
<script language="JavaScript1.2" type="text/javascript">
      fwLoadMenus();
</script>

      <table width="689" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
          <td rowspan="2" colspan="5" align="center" valign="bottom"></td>
          <td colspan="3" align="center" valign="middle"></td>
        </tr>
        <tr>
          <td width="70" height="26" align="center" valign="bottom"></td>
        </tr>
      </table>
      <table width="689" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
            
            

<td><a href="../splash.cfm" onMouseOut="FW_startTimeout(), MM_swapImgRestore();" onMouseOver="window.FW_showMenu(window.fw_menu_1,-2,26,null,'home'), MM_swapImage('home','','../images/nav2/HOME_DRK_REV.gif',1);"><img name="home" src="../images/nav2/HOME_REV.gif" height="27" border="0" alt=""></a></td>

<td><a href="http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=15" onMouseOut="FW_startTimeout(), MM_swapImgRestore();" onMouseOver="window.FW_showMenu(window.fw_menu_2,-2,26,null,'magic_menus'), MM_swapImage('magic_menus','','../images/nav2/Menu_DRK_REV.gif',1);"><img name="magic_menus" src="../images/nav2/Menu_REV.gif" height="27" border="0" alt=""></a></td>

<td><a href="http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=77" onMouseOut=" MM_swapImgRestore();" onMouseOver="window.FW_showMenu(window.fw_menu_3,-2,26,null,'food_info'), MM_swapImage('food_info','','../images/nav2/food_info_DRK_REV.gif',1);"><img name="food_info" src="../images/nav2/food_info_REV.gif" height="27" border="0" alt=""></a></td>

<td><a href="http://www.mysite.com/customers/index.cfm?fuseaction=contact_us" onMouseOut="MM_swapImgRestore();"
onMouseOver="window.FW_showMenu(window.fw_menu_4,-2,26,null,'contact_us'),MM_swapImage('contact_us','','../images/nav2/ContactUs_DRK_REV.gif',1);"><img name="contact_us" src="../images/nav2/ContactUs_REV.gif" height="27" border="0" alt=""></a></td>

<td><a href="http://www.mysite.com/info_pages/index.cfm?fuseaction=all&parent_id=38" onMouseOut="FW_startTimeout(), MM_swapImgRestore();" onMouseOver="window.FW_showMenu(window.fw_menu_5,-2,26,null,'about_us'), MM_swapImage('about_us','','../images/nav2/ABOUTUS_DARK_REV.gif',1);"><img name="about_us" src="../images/nav2/ABOUTUS_REV.gif" height="27" border="0" alt=""></a></td>

<td><a href="http://www.mysite.com/customers/index.cfm?fuseaction=sitemap" onMouseOut="FW_startTimeout(), MM_swapImgRestore();" onMouseOver="window.FW_showMenu(window.fw_menu_6,-2,26,null,'sitemap'), MM_swapImage('sitemap','','../images/nav2/SITEMAP_DRK_REV.gif',1);"><img name="sitemap" src="../images/nav2/SITEMAP_REV.gif" height="27" border="0" alt=""></a></td>

<td><img name="blank" src="../images/nav2/BLANK_REV2.gif" height="27" border="0" alt="" width="125"></a></td>  

<td><a href="https://www.mysite.com/customers/index.cfm?fuseaction=newuser" onMouseOut="FW_startTimeout(), MM_swapImgRestore();" onMouseOver="window.FW_showMenu(window.fw_menu_7,-2,26,null,'register'), MM_swapImage('register','','../images/nav2/REGISTER_DRK_REV.gif',1);"><img name="register" src="../images/nav2/REGISTER_REV.gif" height="27" border="0" alt=""></a></td>

<td><a href="https://www.mysite.com/customers/index.cfm?fuseaction=myaccount" onMouseOut="FW_startTimeout(), MM_swapImgRestore();" onMouseOver="window.FW_showMenu(window.fw_menu_8,-2,26,null,'login'), MM_swapImage('login','','../images/nav2/LOGIN_DRK_REV.gif',1);"><img name="login" src="../images/nav2/LOGIN_REV.gif" height="27" border="0" alt=""></a></td>


Then, further down the page, I have:

<td width="222"><A HREF="javascript:newLocation(theTopLeftURLs[thisTopLeftImage])" onmouseover="window.status='Click Here'; return true;" onmouseout="window.status=''; return true;"><IMG SRC="images/chicken_splash.gif" ID="imgTopLeft" BORDER=0 alt="" width="221" height="100" border="0"></A></td>
                  
                  <SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">
                        <!--
                              var tlImg = document.getElementById("imgTopLeft");

                              // Creates an array of images.
                              var theTopLeftImages = new Array('images/chicken_splash.gif','images/shrimp_splash.gif','images/splash_quiche.gif','images/tenderloin_splash.gif');

                              // Creates an array of urls to go with the images.
                              var theTopLeftURLs = new Array('http://www.mymysite.com','http://www.mymysite.com','http://www.mymysite.com','http://www.mymysite.com');
                              var thisTopLeftImage = 0;
                              var imgCt = theTopLeftImages.length;

                              // Rotates the top left tile images every three seconds.
                              function rotateTopLeft() {
                                    if (tlImg.complete) {
                                        thisTopLeftImage++;
                                        if (thisTopLeftImage == imgCt) {
                                              thisTopLeftImage = 0;
                                        }
                                    // Changes the image source.
                                    tlImg.src=theTopLeftImages[thisTopLeftImage];
                                    }
                                      // Sets the timer for the image rotation.
                                      setTimeout("rotateTopLeft()", 5 * 1000);
                              }
                        //-->
                  </SCRIPT>

Thanks very much!
0
 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16895741


I'm not able to get that page loading with all the missing html. do you have an online example?
0
 

Author Comment

by:mel200
ID: 16896598
Sure.. If you go to http://dev.magickitchen.com, you will see the error. Thanks!
0
 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16896955

this is pretty tough to sift through, Where did you get this code?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16897097


this may not solve your problem but sometime funny thing happen when your DOM is messed up:


            <ul>
              <div align="center">
              <li><b>Healthy complete meals the whole family can enjoy</b>
                <li><b>We use the finest, freshest vegetables and herbs and <br>
                  wherever possible hormone-and-antibiotic free meats</b>
                <li><b>Flash frozen and vacuum sealed to preserve freshness</b>
                <li><b>Delicious, Nutritious Convenience!</b>
            </ul>
            </div>


should be:
            <div align="center">
            <ul>
              <li><b>Healthy complete meals the whole family can enjoy</b>
                <li><b>We use the finest, freshest vegetables and herbs and <br>
                  wherever possible hormone-and-antibiotic free meats</b>
                <li><b>Flash frozen and vacuum sealed to preserve freshness</b>
                <li><b>Delicious, Nutritious Convenience!</b>
            </ul>
            </div>


0
 

Author Comment

by:mel200
ID: 16897462
Hi- I got this code from a series of developers who have worked on this site through the last five years or so. Pretty convoluted, isn't it? Thanks-I ddn't realzie the div should be in front of the ul. I'll try that....
0
 

Author Comment

by:mel200
ID: 16897496
Hmmm... nope, still have the same error. What does menuLayer is null or not an object mean, anyway? Thanks!
0
 
LVL 10

Accepted Solution

by:
0h4crying0utloud earned 500 total points
ID: 16897613

In the function "FW_showMenu(menu, x, y, child, imgname) {...}" the "menu" parameter is not being passed correctly somewhere...  so when the line that tries to access menu.menuLayer comes along you get an error message.  the page seems to work ok in FireFox but it still reports the error in the logs.
0
 

Author Comment

by:mel200
ID: 16897753
Ok, I had wondered about this.. I'll try to say this correctly, but since I'm java-naive, it may take some more explaining on my part... bear with me...

On my menu display page, I only have
window.fw_menu_2
window.fw_menu_3
window.fw_menu_4
window.fw_menu_5

I don't have:
window.fw_menu_1
window.fw_menu_6
window.fw_menu_7
window.fw_menu_8

Although I have eight headers on my menu. (home, menu, food info, contact us, about us, site map, register, login.)

I want to have them on there, because them my menu will act correctly, but if I add them I get an odd line under the header when I hover. (I have made this change at the url I gave above, which is our development site, so you can see what I mean. you'll especially see it if you hover over LOGIN).

Here is the code from that page, maybe this helps:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
      <!--
      
      
      function fwLoadMenus()
     {
      if (window.fw_menu_0) return;
       window.fw_menu_1 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"##000000","##FFFFFF","##F5F5EB","##FF5416",7); //F4F217 17B3F4
      
      window.fw_menu_2 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"##000000","##FFFFFF","##F5F5EB","##FF5416",7); //F4F217 17B3F4
    fw_menu_2.addMenuItem("Spring Menu","location='/catalog/index.cfm?fuseaction=cust_catalog&product_id=384&Cat_sort=1&rest_cat=0&pageRef=current_month_cust'");
        fw_menu_2.addMenuItem("Summer Menu","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=18'");
          fw_menu_2.addMenuItem("Meal Packages","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=85'");
         fw_menu_2.hideOnMouseOut=true;
        
           window.fw_menu_3 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"##000000","##FFFFFF","##F5F5EB","##FF5416",7); //F4F217 17B3F4
    fw_menu_3.addMenuItem("Nutrition ","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=31'");
        fw_menu_3.addMenuItem("Thawing & Reheating","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=33'");
         fw_menu_3.hideOnMouseOut=true;
        
          window.fw_menu_4 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"##000000","##FFFFFF","##F5F5EB","##FF5416",7); //F4F217 17B3F4
        fw_menu_4.addMenuItem("Newsletter","location='#request.home#/customers/index.cfm?fuseaction=newsletter'");
         fw_menu_4.hideOnMouseOut=true;
        
            window.fw_menu_5 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"##000000","##FFFFFF","##F5F5EB","##FF5416",7); //F4F217 17B3F4
<!---     fw_menu_5.addMenuItem("Overview","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=38'");   --->      
      fw_menu_5.addMenuItem("Corporate Presentation","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=78'");
fw_menu_5.addMenuItem("Fundraising","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=79'");
fw_menu_5.addMenuItem("Our Staff","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=36'");
fw_menu_5.addMenuItem("Newsletter","location='#request.home#/customers/index.cfm?fuseaction=newsletter'")
fw_menu_5.addMenuItem("Terms and Conditions","location='#request.home#/info_pages/index.cfm?fuseaction=all&parent_id=82'");
         fw_menu_5.hideOnMouseOut=true;
        
       window.fw_menu_6 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"##000000","##FFFFFF","##F5F5EB","##FF5416",7); //F4F217 17B3F4

 window.fw_menu_7 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"##000000","##FFFFFF","##F5F5EB","##FF5416",7); //F4F217 17B3F4

 window.fw_menu_8 = new Menu("test2",170,16,"Verdana, Arial, Helvetica, sans-serif",11,"##000000","##FFFFFF","##F5F5EB","##FF5416",7); //F4F217 17B3F4
        
 writeMenus();
    }
      
      
      
      // -->
      </SCRIPT>

Thanks again!
0
 

Author Comment

by:mel200
ID: 16904097
Thanks, I'm going to post this as a separate question. I think you pointed me in ther right direction, though.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now