this.contextMenu is null

Since new Firefox version, we get this error with menubar dhtmlxMenu v.1.0 Standard edition build 80512. In IE works everything well.

this.contextMenu is null
dhtmlxmenubar_cp.js Line 11

Is it possible to fix this? An update to the new version is not possible, because we use other older components, we have to update also in this case.

function dhtmlXContextMenuObject(width,height,gfxPath,httpsdummy){this.menu=new dhtmlXMenuBarObject(document.body,width,height,“”,1,gfxPath,httpsdummy);this.menu.setMenuMode(“popup”);this.menu.hideBar();this.menu.contextMenu=this;this.menu.enableWindowOpenMode(false);this.menu.setOnClickHandler(this._innerOnClick);this.aframes=new Array();this.registerFrame(window);return this};dhtmlXContextMenuObject.prototype.registerFrame=function(awin){this.aframes[this.aframes.length]=awin};dhtmlXContextMenuObject.prototype.setContextMenuHandler=function(func){if (typeof(func)==“function”) this.onClickHandler=func;else this.onClickHandler=eval(func)};dhtmlXContextMenuObject.prototype.openAt=function(x,y,id,smartPosition){this.espc=convertStringToBoolean(smartPosition);var f=new Object;f.button=2;f.clientX=parseInt(x);f.clientY=parseInt(y);var start=new Object;start.contextMenuId=id;start.contextMenu=this;start.a=this._contextStart;start.a(document.body,f);this.espc=null};dhtmlXContextMenuObject.prototype.disableMenu=function(mode){this._dsbd=convertStringToBoolean(mode)};dhtmlXContextMenuObject.prototype.setOnShowMenuHandler=function(func){if (typeof(func)==“function”) this.onShowHandler=func;else this.onShowHandler=eval(func)};dhtmlXContextMenuObject.prototype.setContextMenuPosition=function(left,top){this._msTop=parseInt(top);this._msLeft=parseInt(left)};dhtmlXContextMenuObject.prototype._innerOnClick=function(id){var that=document.body.contextMenu;if (that.contextZone.ownerDocument){if (that.contextZone.ownerDocument.body.onclick)that.contextZone.ownerDocument.body.onclick()}else if (document.body.onclick)document.body.onclick();if (that.onClickHandler)return that.onClickHandler(id,that.zoneId,that.contextZone);return true};dhtmlXContextMenuObject.prototype.setContextZone=function(htmlObject,zoneId){if (typeof(htmlObject)!=“object”)
htmlObject=document.getElementById(htmlObject);if (!htmlObject.contextMenu)htmlObject.contextOnclick=htmlObject.onmouseup;htmlObject.selfobj = this;htmlObject[_isMacOS?“oncontextmenu”:“onmouseup”]= function(e){this.selfobj._contextStart(this,e)};htmlObject.contextMenu=this;htmlObject.contextMenuId=zoneId};dhtmlXContextMenuObject.prototype._contextStart=function(obj,e){if ((_isIE)&&(window.event))
event.srcElement.oncontextmenu = function(){event.cancelBubble=true;return false};if (e && e.preventDefault)e.preventDefault();if(!this.contextMenu)this.contextMenu = this;var win = obj.ownerDocument?obj.ownerDocument.parentWindow:window;if(!win){win = obj.ownerDocument.defaultView};var a=this.contextMenu.menu.topNod;a.style.position=“absolute”;if (!e){e=win.event};if (document.body.onclick)document.body.onclick();if ((!_isMacOS)&&((!e)||(e.button!=2)))
{if (obj.contextOnclick)obj.contextOnclick();return true}else {if (this.contextMenu._dsbd)return true;if (this.contextMenu.onShowHandler){var z=this.contextMenu.onShowHandler(obj.contextMenuId);if ((typeof(z)==“boolean”)&&(!z)) return};this.contextMenu.menu.showBar()};var winScreenTop = window.screenTop;if ((!winScreenTop)&&(winScreenTop!=0)){winScreenTop = window.screenY+window.outerHeight-window.innerHeight};var winScreenLeft = window.screenLeft;if((!winScreenLeft)&&(winScreenLeft!=0)){winScreenLeft = window.screenX+window.outerWidth-window.innerWidth-4};var dEl0=window.document.documentElement;var dEl1=window.document.body;if(e.screenY-winScreenTop+a.offsetHeight-(dEl0.scrollTop||dEl1.scrollTop)> (dEl0.clientHeight||dEl1.clientHeight)){var verCor = a.offsetHeight
}else
var verCor = ((this.contextMenu._msTop*(-1))||0);var corrector = new Array((dEl0.scrollLeft||dEl1.scrollLeft)+(this.contextMenu._msLeft||0),verCor-(dEl0.scrollTop||dEl1.scrollTop));if ((!e.screenY)&&(e.clientX))
{a.style.top = e.clientY+“px”;a.style.left = e.clientX+“px”}else
{a.style.top = e.screenY-winScreenTop-corrector[1]+“px”;a.style.left = e.screenX-winScreenLeft+corrector[0]+“px”};if(!_isIE){a.style.top = e.clientY-corrector[1]+“px”;a.style.left = e.clientX+corrector[0]+“px”};this.contextMenu.correctMenuPosition(a);if (a.ieFix){a.ieFix.style.top=a.style.top;a.ieFix.style.left=a.style.left};win.document.body.oncontextmenu=new Function(“document.body.oncontextmenu=new Function(‘if (document.body.onclick)document.body.onclick();return false;’);return false;”);for (var i=0;i<this.contextMenu.aframes.length;i++){if (this.contextMenu.aframes[i].document)this.contextMenu.aframes[i].document.body.selfobj = this;this.contextMenu.aframes[i].document.body.onclick=function(e){this.selfobj.contextMenu._contextEnd(e)}};document.body.contextMenu=this.contextMenu;this.contextMenu.contextZone=obj;this.contextMenu.zoneId=obj.contextMenuId;return false};dhtmlXContextMenuObject.prototype.correctMenuPosition=function(panel,mode){var xs=document.body.offsetWidth+document.body.scrollLeft;var yval = document.body.offsetHeight;if(yval == 0 && document.defaultView && document.defaultView.innerHeight)yval = document.defaultView.innerHeight;var ys = yval - 15 + document.body.scrollTop;if (document.body.parentNode.scrollTop)ys=document.body.parentNode.offsetHeight+document.body.parentNode.scrollTop;if ((panel.offsetWidth+parseInt(panel.style.left))>xs)
{var z=parseInt(panel.style.left)-panel.offsetWidth;if ((z<0)||(this.espc))
z=xs-panel.offsetWidth;if (z<0)z=0;panel.style.left=z+“px”;if (panel.ieFix)panel.ieFix.style.left=z+“px”};if ((panel.offsetHeight+parseInt(panel.style.top))>ys)
{var z=parseInt(panel.style.top) - panel.offsetHeight;if ((z<0)||(this.espc))
z=ys-panel.offsetHeight;if (z<0)z=0;panel.style.top=z+“px”;if (panel.ieFix)panel.ieFix.style.top=z+“px”};if (!mode)this.correctMenuPosition(panel,1)};dhtmlXMenuBarObject.prototype.correctMenuPosition=dhtmlXContextMenuObject.prototype.correctMenuPosition;dhtmlXContextMenuObject.prototype._contextEnd=function(e){var menu=this.menu;menu._closePanel(menu);menu.lastOpenedPanel=“”;menu.lastSelectedItem=0;menu.hideBar();for (var i=0;i<this.aframes.length;i++)if (this.aframes[i].document){this.aframes[i].document.body.onclick=null;this.aframes[i].document.body.oncontextmenu=null};return false};

Please, provide us a completed demo to reproduce your issue:
docs.dhtmlx.com/doku.php?id=othe … leted_demo

Hi, I had the same problem and made the following changes :

in

dhtmlxgrid.js line 822

changed

el.contextMenu=this._ctmndx;

with

Object.defineProperty(el, “contextMenu”, {value : this._ctmndx,
writable : true,
configurable : true,
enumerable : true});

and in

dhtmlXMenuBar_cp.js line 156

changed

document.body.contextMenu=this.contextMenu;

with

Object.defineProperty(document.body, “contextMenu”, {value : this.contextMenu,
writable : true,
configurable : true,
enumerable : true});

Tested in FF12 and IE8

Hope this will be usefull

Hi, I have this same issue…
TypeError: this.contextMenu is null
dhtmlXContextMenuObject.prototype._contextStart(obj=td.standartTreeRow, e=mousedown clientX=192, clientY=158)dhtmlXM…r_cp.js (lin

I am running standard version 1.0. I know I need to upgrade, just don’t have the time right now. Any help will be appreciated. Works in IE 11 but not Firefox or Chrome.

aMenu=new dhtmlXContextMenuObject('120',0,"myMenu");
aMenu.menu.setGfxPath("/dtreex/dhtmlxMenu/codebase/imgs/");        
aMenu.menu.loadXML("/myMenu.xml");                
aMenu.setContextMenuHandler(onButtonClick);
aMenu.setOnShowMenuHandler(ChangeMenu)

tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
tree.loadXML("/menus/<cfoutput>#FORM.mallID#</cfoutput>.xml");
tree.setImagePath("/dtreex/dhtmlxtree/codebase/imgs/csh_bluefolders/");
tree.enableContextMenu(aMenu); //link context menu to tree	
tree.enableItemEditor(false);
tree.enableDragAndDropScrolling(true)	
tree.enableKeyboardNavigation(true) 	
tree.enableMultiselection(false,true);						
tree.enableDragAndDrop(true,false);
tree.setDragBehavior("sibling",true);
tree.setDragHandler(myDragHandler);	
tree.enableHighlighting(true);
tree.enableTreeLines(true);

// tree.setOnRightClickHandler(myRightClick);
tree.enableSmartXMLParsing(true);
tree.setOnEditHandler(“myEditHandler”);
tree.setOnLoadingEnd(“loadDone”);
tree.setOnDblClickHandler(doOnDClick);
tree.setSerializationLevel(true,true);
tree.setOnClickHandler(myClickFunct)
// tree.setDragHandler(tondrag);
tree.setDropHandler(tondrop);

Locally works fine.
Dear customers, if you can provide a demo on support@dhtmlx.com with link to this topic we can to inspect it anf help you.
docs.dhtmlx.com/auxiliary_docs__ … pport.html

Hi,
I have created a test page that shows the issue.
This page works on IE 11.096 and on the IE tab of chrome. But it does not work on Firefox or Chrome.
The problem is the right click menu function. On the left side on the page there is the tree. Right click on any child item and you should see a context menu. On IE it works. On firefox I get the browsers right click options and no my menu options. On Chrome I get small empty box.
Hope this test page will help you help me.
URL: uniformsmallusa.com/testdhtmlx.cfm
Thanks for looking into this…
Best Regards,
Joe

Hi,
An update. I installed 1.0.6 from 1.0.5 and now it is working on Chrome and IE. However, it still is not working on Firefox.

Hi, joeunderbar
Sorry, but your test page is empty…

Hi, sorry… Actually, it’s not empty. My server is blocking your IP address. Must be on some list.
I checked my logs and I see you trying to access the page at . I have white listed your IP address, so please try again. Thanks for the help.
Best Regards,
Joe

No result :frowning: