CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: 'this.menu'

  1. #1
    Join Date
    Apr 2008
    Posts
    4

    'this.menu'

    Hi every one I need someone to help me with javascript I'm receiving this error message -'this.menu' is not null or an object. its on this line:this.submenus = this.menu.getElementsByTagName("div");
    this is part of my code

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="_ctl0_Head1"><title>
    	Careers in pharmacy - login
    </title><link rel="stylesheet" type="text/css" 
    
    href="Admin/Design/spurintranet.css" /><link rel="stylesheet" type="text/css" href="Admin/Design/Menu.css" /><script type="text/javascript">
    
    function SDMenu(id) 
    {
    	if (!document.getElementById || !document.getElementsByTagName)
    		return false;
    		
    	this.menu = document.getElementById(id);
    	this.submenus = this.menu.getElementsByTagName("div");
    	this.remember = true;
    	this.speed = 3;
    	this.markCurrent = true;
    	this.oneSmOnly = true;
    }
    Last edited by PeejAvery; April 22nd, 2008 at 09:29 AM. Reason: Added code tags.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: 'this.menu'

    Can you post more relevant code so that we can actually work with it?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Nov 2004
    Location
    Slough, UK
    Posts
    184

    Re: 'this.menu'

    Quote Originally Posted by msandlana
    Hi every one I need someone to help me with javascript I'm receiving this error message -'this.menu' is not null or an object. its on this line:this.submenus = this.menu.getElementsByTagName("div");
    this is part of my code

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="_ctl0_Head1"><title>
    	Careers in pharmacy - login
    </title><link rel="stylesheet" type="text/css" 
    
    href="Admin/Design/spurintranet.css" /><link rel="stylesheet" type="text/css" href="Admin/Design/Menu.css" /><script type="text/javascript">
    
    function SDMenu(id) 
    {
    	if (!document.getElementById || !document.getElementsByTagName)
    		return false;
    		
    	this.menu = document.getElementById(id);
    	this.submenus = this.menu.getElementsByTagName("div");
    	this.remember = true;
    	this.speed = 3;
    	this.markCurrent = true;
    	this.oneSmOnly = true;
    }
    The only thing that can be inferred from the code you posted is that the ID supplied to the SDMenu function does not correspond to an element with the same id in the HTML.

    I assume you have of course already checked this. However, you also need to ensure that the HTML has been loaded fully by the browser before carrying out any operations that require finding or manipulating the HTML. I suggest that if you have not already done so, put the calling code into the onload event handler for the window object.

    Also, I suggest you put an error checker in the SDMenu function to test the document.getElementById operation returns an element and not null.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || ClickOnline ||

    Did I ever say I was an expert?

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Please mark threads resolved by going to the thread tools menu and clicking the Mark Thread Resolved button.

    Has a post really helped you? Please Rate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured