C. *_*Lee 12 javascript events contextmenu
document.addEventListener('contextmenu', function (e) {
e.preventDefault()
e.stopPropagation()
e.returnValue = false
e.cancleBubble = true
})
Run Code Online (Sandbox Code Playgroud)
没门?
编辑:document.oncontextmenu = null不起作用.
PS我不能拥有监听器功能的引用,因为我不是阻止上下文菜单的站点的所有者.
use*_*984 18
在这种情况下我使用我的书签:
javascript:(function(w){
var arr = ['contextmenu','copy','cut','paste','mousedown','mouseup','beforeunload','beforeprint'];
for(var i = 0, x; x = arr[i]; i++){
if(w['on' + x])w['on' + x] = null;
w.addEventListener(x, function(e){e.stopPropagation()}, true);
};
for(var j = 0, f; f = w.frames[j]; j++){try{arguments.callee(f)}catch(e){}}})(window);
Run Code Online (Sandbox Code Playgroud)
如果您真的很addEventListener绝望,请尝试在调用之前添加此内容。它适用于 FF 和 Chrome。我没有检查其他任何东西。
document.superListener = document.addEventListener;
document.addEventListener = function(type, listener, useCapture){
if(type != 'contextmenu')
document.superListener(type, listener, !!useCapture);
};
Run Code Online (Sandbox Code Playgroud)
这可能不是最好的做事方式,但它应该是针对您的具体示例完成的工作:)
| 归档时间: |
|
| 查看次数: |
5192 次 |
| 最近记录: |