Question

How to get the position, height and width of the right click context menu of any browser using JavaScript/jQuery? Here is the image: Context Menu

No correct solution

OTHER TIPS

You can't. It's not a DOM element. But you can override the right click event and create your own context menu. (Here's a plugin for you to do that in jQuery)

You can get the position of the mouse cursor when right clicking with the following jQuery code:

$('html, body').mousedown(function(event) {
    if (event.which == 3) {
        console.log('mouse position:', 'horizontal: '+event.clientX, 'vertical: ' +event.clientY);
    }
});

You can try this out here: http://jsfiddle.net/x4Uae/1/

This will give you the mouse position relative to the browser screen the instant the right mouse button is pressed. I tested this in Firefox 28 and Internet Explorer 11 and it works in both.

As others have said, you can't get the width and height of the right click context menu since it is not part of the DOM.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top