how to disable right-click contextMenu - but enable for form elements 
Author Message
 how to disable right-click contextMenu - but enable for form elements
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.

Thanks in advance. Cheers...

Scott.



Wed, 18 Feb 2004 01:02:53 GMT  
 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


Wed, 18 Feb 2004 01:35:42 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Enable & Disable Form Text Elements

2. disable mouse right-click

3. Disable right click

4. Disable Right Click--> IE4

5. disable shortcut in right click

6. Disable right click

7. Disabling the right-click menu on a WebBrowser component

8. Disable right click

9. form repost right mouse click-refresh

10. x-browser way to disable form elements?

11. Check if form element is disabled

12. Finding # of specific element in forms elements collection

 

 
Powered by phpBB® Forum Software