how to disable right-click contextMenu - but enable for form elements
Quote:
> I know how to disable the right-click context menu, but I still want to
> allow it if the user right-clicks on a form element so that the simple Cut /
> Copy / Paste / Delete / Select All menu appears.
> Is there a better way to do this then the following?
> <body
> oncontextmenu="if(window.event.srcElement.tagName == 'INPUT'){return
> true;}else{return false;}">
> And what would be the best way to do this in a behavior file so I don't have
> to edit all my pages directly? This is for MSIE 5.x specifically.
document.oncontextmenu=CheckContextMenu;
function CheckContextMenu(){
var et = event.srcElement.tagName.toUpperCase();
var allowed = "INPUT,TEXTAREA,";
return (allowed.indexOf(et+",")>=0)
Quote:
}
--
Thor Larholm
<URL: http://www.jibbering.com/faq/> FAQ for comp.lang.javascript