/    Sign up×
Community /Pin to ProfileBookmark

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;
}

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@parth_patelauthorFeb 14.2009 — The "menubar" constructor is called from execute_menu, which is eventually called from onreadystatechange event handler of xmlHttp object defined in menubar_.
Copy linkTweet thisAlerts:
@ScriptageFeb 14.2009 — 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);
//
[B]return xmlHttp;[/B]
}

[/CODE]
Copy linkTweet thisAlerts:
@parth_patelauthorFeb 14.2009 — 

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
[/CODE]

==================================================================
Copy linkTweet thisAlerts:
@parth_patelauthorFeb 14.2009 — 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;
}
[/CODE]
×

Success!

Help @parth_patel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...