www.webdeveloper.com
Results 1 to 5 of 5

Thread: menubar not a contructor

  1. #1
    Join Date
    Jan 2009
    Posts
    7

    menubar not a contructor

    Hey guys,

    I am having a weird error in Mozilla.

    when i try and execute menubar_ function, it gives me an error that "menubar is not a constructor" in mozilla firefox only. It runs fine with IE.

    Does anyone have any idea?

    thanks,
    Parth

    =========================================================

    function menubar(xmldoc){

    alert(xmldoc);
    // Parse XML ....
    // x element has responseXML data

    no = 4;
    ....
    ...
    ...
    ..
    //
    this.redo = function (){
    ....
    ...
    ..
    }
    }

    var x;

    function execute_menu(xml){

    x = new menubar(xml);

    }


    function menubar_(xmldoc){

    var xmlHttp;

    if (!window.ActiveXObject)
    xmlHttp= new XMLHttpRequest();
    else
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

    xmlHttp.open("GET",xmldoc,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Connection", "close");
    //
    // set the function on state change, which is the action to be performed when state changes
    xmlHttp.onreadystatechange=function (){
    if(xmlHttp.readyState==4)
    execute_menu(xmlHttp.responseXml);
    }
    // now make a request
    xmlHttp.send(null);
    //
    return x;
    }

  2. #2
    Join Date
    Jan 2009
    Posts
    7
    The "menubar" constructor is called from execute_menu, which is eventually called from onreadystatechange event handler of xmlHttp object defined in menubar_.

  3. #3
    Join Date
    Nov 2002
    Location
    England
    Posts
    693
    Try:

    Code:
    function menubar_(xmldoc){
    
    var xmlHttp;
    
    if (!window.ActiveXObject)
    xmlHttp= new XMLHttpRequest();
    else
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    
    xmlHttp.open("GET",xmldoc,true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Connection", "close");
    // 
    // set the function on state change, which is the action to be performed when state changes
    xmlHttp.onreadystatechange=function (){ 
    if(xmlHttp.readyState==4)
    execute_menu(xmlHttp.responseXml);
    }
    // now make a request
    xmlHttp.send(null);
    //
    return xmlHttp;
    }

  4. #4
    Join Date
    Jan 2009
    Posts
    7
    The constructor Error is gone ... but pops up an exception.
    ==================================================================
    Code:
    Error: [Exception... "Cannot convert WrappedNative to function"  nsresult: "0x8057000d (NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN)"  location: "JS frame :: file:///C:/Program%20Files/Apache/htdocs/My%20Website/js/menubar.js :: execute_menu :: line 153"  data: no]
    Source File: file:///C:/Program%20Files/Apache/htdocs/My%20Website/js/menubar.js
    Line: 153
    ==================================================================

  5. #5
    Join Date
    Jan 2009
    Posts
    7

    menubar.js file

    here is the whole menubar.js file ... if you want to refer anything in there.

    Code:
    function menubar(xmldoc){
    		
    		alert(xmldoc);
    	// Parse XML ....
    	// x element has responseXML data
    	
    	no = 4;
    	
    	//
    	
    	var src = [
    	{
    		original: 'img/1.png',
    		onmouseover: 'img/1-o.png',
    		onmousedown: 'img/1-c.png'
    	},
    	{
    		original: 'img/2.png',
    		onmouseover: 'img/2-o.png',
    		onmousedown: 'img/2-c.png'
    	},
    	{
    		original: 'img/3.png',
    		onmouseover: 'img/3-o.png',
    		onmousedown: 'img/3-c.png'
    	},
    	{
    		original: 'img/4.png',
    		onmouseover: 'img/4-o.png',
    		onmousedown: 'img/4-c.png'
    	},
    	{
    		original: 'img/buttony1.png',
    		onmouseover: 'img/buttony.png',
    		onmousedown: 'img/buttony2.png'
    	},
    	{
    		original: 'img/buttonv1.png',
    		onmouseover: 'img/buttonv.png',
    		onmousedown: 'img/buttonv2.png'
    	},
    	{
    		original: 'img/buttonr1.png',
    		onmouseover: 'img/buttonr.png',
    		onmousedown: 'img/buttonr2.png'
    	},
    	{
    		original: 'img/buttong1.png',
    		onmouseover: 'img/buttong.png',
    		onmousedown: 'img/buttong2.png'
    	}
    	];
    
    	var names = [
    				 "Home","Resume","Projects","Contact Me","","","","","","","","","","","",""
    				 ];
    	
    	var submenu_names = [ [],["Education","Academic Exp","Professional Exp","Activities"],[],[],[],[],[] ]; 
    
    	var metadata ={
    		left:'5px',
    		top:'100px',
    		width:'145px',
    		height:'35px',
    		font_size:'20px',
    	};
    	
    	var submenudata = {
    		left:'20px',
    		top:'100px',
    		width:'120px',
    		height:'25px',
    		font_size:'16px'
    	};
    	
    	var x = new Array();
    	
    	for (var  i=0 ; i < no; i++){	
    		
    		x[i] = new button('button'+i,src[i],names[i], metadata);
    		
    		x[i].parent = this;
    		
    		
    		
    		if(submenu_names[i].length > 0)
    		{
    			submenudata.top = parseInt(metadata.top) + parseInt(x[i].div.style.height) + 'px';
    			
    			for(var j=0;j<submenu_names[i].length ;j++)
    			{
    				x[i].submenu[j] = new button('button'+i+j,src[i], submenu_names[i][j], submenudata);
    				submenudata.top = parseInt(submenudata.top) + parseInt(x[i].submenu[j].div.style.height) + 3 +'px';	
    				x[i].submenu[j].toggleVisibility(false);				
    			}
    			// metadata.top = parseInt(submenudata.top) + 'px';
    			metadata.top = parseInt(metadata.top) + parseInt(x[i].div.style.height) + 3 +'px';			
    			x[i].div.onclick = function () { this.parent.toggleSubmenu(); this.parent.parent.redo(); };
    		}
    		else{
    			metadata.top = parseInt(metadata.top) + parseInt(x[i].div.style.height) + 3 +'px';	
    		}
    		
    	}	
    		
    	this.redo = function (){
    		
    		var mdata ={
    			left:'20px',
    			top:'100px',
    			width:'200px',
    			height:'35px',
    			font_size:'20px',
    		};
    		
    		var submdata = {
    			left:'40px',
    			top:'100px',
    			width:'180px',
    			height:'25px',
    			font_size:'16px'
    		};
    		
    			for (var  i=0 ; i < no; i++){	
    			
    				x[i].div.style.top = parseInt(mdata.top) + 'px';
    				x[i].img.style.top = x[i].div.style.top;
    							
    				if(submenu_names[i].length > 0 && x[i].submenu[0].div.style.visibility=="visible" )
    				{
    					submdata.top = parseInt(mdata.top) + parseInt(x[i].div.style.height) + 'px';
    					
    					for(var j=0;j<submenu_names[i].length ;j++)
    					{
    						x[i].submenu[j].div.style.top = parseInt(submdata.top) + 3 + 'px'; //new button('button'+i+j,src[i], submenu_names[i][j], submdata);
    						x[i].submenu[j].img.style.top = x[i].submenu[j].div.style.top;
    						submdata.top = parseInt(submdata.top) + parseInt(x[i].submenu[j].div.style.height) + 3 +'px';	
    					}
    					mdata.top = parseInt(submdata.top) + 3 + 'px';
    				}
    				else{
    					mdata.top = parseInt(mdata.top) + parseInt(x[i].div.style.height) + 3 +'px';	
    				}
    		  }	
    			
    	}
    //	x[0].toggleVisibility(false);	
    }
    
    var x;
    function execute_menu(xml){
    	x = new menubar(xml);	
    }
    
    
    function menubar_(xmldoc){
    
    	var xmlHttp;
    	
    	if (!window.ActiveXObject)
         xmlHttp= new XMLHttpRequest();
       else
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    	
    	// now make a request
    	 xmlHttp.open("GET",xmldoc,true);
    	 xmlHttp.overrideMimeType('text/xml');
    	 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    	 xmlHttp.setRequestHeader("Connection", "close");
      //	
      // set the function on state change, which is the action to be performed when state changes
    	xmlHttp.onreadystatechange=function (){ 
    		if(xmlHttp.readyState==4)
    				execute_menu(xmlHttp.responseXml);
    	}
      // now make a request
    	xmlHttp.send(null);
      //
      return xmlHttp;
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles