Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two right-click menus on one page? 1

Status
Not open for further replies.

coospaa

Programmer
May 1, 2003
33
SG
I was asked to build two right-click menus on one page. That is if the left portion of the page (say width=100) is right-clicked, it shows one menu; and if the rest portion of the page is right-clicked, it shows another menu. How should I do it?

The page is full of DIVs so i cannot get any ID to identify the "left portion" and "right portion". Is that a way out here?

Thanks in advance.
 
Yes - you can detect the mouse coordinates in the onmousedown event. This should get you started:

Code:
document.onmousedown = function(eventData) {
	eventData = (eventData) ? eventData : event;
	var xPos = eventData.clientX;
	var yPos = eventData.clientY;
}

The code is cross browser (tested working in IE6, NN7, FF1, Opera7, and Safari).

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top