范文 |
最简单的所有都屏蔽右键菜单 代码如下: <script type="text/javascript"> document.body.oncontextmenu=new function(){return false;}; </script> 我们希望在INPUT、text、TEXTAREA中可以实现右击,但在其它页面都要屏蔽右键菜单 实例代码 代码如下: <script type="text/javascript"> //屏蔽右键菜单 document.oncontextmenu = function (event){ if(window.event){ event = window.event; }try{ var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; }catch (e){ return false; } } </script> |