在这种情况下如何重新启用上下文菜单? [英] How to re-enable the context menu in this case?

查看:84
本文介绍了在这种情况下如何重新启用上下文菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  document.addEventListener('contextmenu',function(e){
e.preventDefault()
e.stopPropagation()
e.returnValue = false
e.cancleBubble = true
})

没办法? / p>

编辑: document.oncontextmenu = null 无效。



PS我不能拥有监听器函数的引用,因为我不是阻止上下文菜单的站点的所有者。

解决方案

如果你是真的绝望,尝试添加它之前,$ code> addEventListener 被调用。它适用于FF和Chrome。我没有检查任何其他东西。

  document.superListener = document.addEventListener; 
document.addEventListener = function(type,listener,useCapture){
if(type!='contextmenu')
document.superListener(type,listener,!! useCapture);
};

这可能不是最好的办法,但应该是根据您的具体情况完成工作例如:)


document.addEventListener('contextmenu', function (e) {
    e.preventDefault()
    e.stopPropagation()
    e.returnValue = false
    e.cancleBubble = true
})

No way?

Edit: document.oncontextmenu = null does not work.

P.S. I cannot have the reference of the listener function since I am not the owner of the site preventing the context menu.

解决方案

If you are really desperate, try adding this before the addEventListener is called. It works in both FF and Chrome. I didn't check anything else.

document.superListener = document.addEventListener;
document.addEventListener = function(type, listener, useCapture){
    if(type != 'contextmenu')
        document.superListener(type, listener, !!useCapture);
};

It may not be the best way to do things, but it should be the job done on your specific example :)

这篇关于在这种情况下如何重新启用上下文菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆