禁止文本框粘贴功能【支持IE、Mozlla、Firefox等】[转自孟老先生^^]

代码:

<body>
<script type="text/javascript">
//not IE is required
function fncKeyStop(evt)
{
    
if(!window.event)
    {
        
var keycode = evt.keyCode; 
        
var key = String.fromCharCode(keycode).toLowerCase();
        
if(evt.ctrlKey && key == "v")
        {
          evt.preventDefault(); 
          evt.stopPropagation();
        }
    }
}
</script>
<input onkeydown="fncKeyStop(event)" onpaste="return false" oncontextmenu = "return false;" />
</body>

 已知的问题:不能屏蔽Firefox的菜单栏上的“paste”。:(
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1789564

原文地址:https://www.cnblogs.com/witer666/p/942472.html