屏蔽web页面的右键,但不屏蔽输入框中的右键

  if (document.layers) {
            document.captureEvents(Event.MOUSEDOWN);
        }
        document.onmousedown = click;
        document.oncontextmenu = new Function("return false;")

        
function click(e) {
            e = e || event;
            
if (e.button == 2) {
                
var tag = e.srcElement || e.target;
                
if (tag.type == "text" || tag.type == "textarea") {
                    document.oncontextmenu = new Function("return true;")
                }
                
else {
                     
                    document.oncontextmenu = new Function("return false;")
                }
            }

        }
posted @ 2010-07-29 10:30  瑞君  Views(198)  Comments(0Edit  收藏  举报