I'm using a context-menu jquery plugin and I need to detect what browsers support this. How can this be done?
I heard some versions of opera and safari don't support this right-click overriding business
I'm using a context-menu jquery plugin and I need to detect what browsers support this. How can this be done?
I heard some versions of opera and safari don't support this right-click overriding business
You can create and fire a contextmenu event manually. If you set the proper handler, you can detect if the handler is called or not.
Here is an example (using jQuery for event creation and observation):
function testContextMenuEvent() {
var supported = false;
function handler(e) {
supported = true;
e.stopPropagation();
}
$(document).bind('contextmenu', handler);
var evt = jQuery.Event("contextmenu");
$(document).trigger(evt);
$(document).unbind('contextmenu', handler);
return supported;
}
Here is a test page : http://jsfiddle.net/Hk4xA/6/
edit2: the DOM has striken again. I forgot that createEvent
totally doesn't work on IE. So instead I used jQuery for the event creation too.