禁用右键单击 [英] Disabling Right click

查看:90
本文介绍了禁用右键单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在没有修改网站的源代码(html,css和javascript)的情况下,是否有任何方法可以禁用在iframe(html控件)或Silverlight中的Web浏览器控件中的网站上的右键单击? (它不应该通过添加js到另一个网站源代码)... ???

Is there any way of disabling right click on a website inside an Iframe( html control ) or a web browser control in Silverlight ... without modifying the source code( html , css & javascript ) of the website ? (it should not be by Adding a js to another websites source code)...???

推荐答案





只需将您的查询放在Google上即可获得大量解决方案......

[ ^ ]


试试这个



只需将其放入您的HTML代码中

Try this one

Just put it in your HTML code
<script type="text/javascript">
function disableRightClick(btnClick) {
    if (navigator.appName == "Netscape" && btnClick.which == 3) { // check for netscape and right click
        alert("Right Click is disabled");
        return false;
    }
    else if (navigator.appName =="Microsoft Internet Explorer" && event.button == 2) { // for IE and Right Click
        alert("Right Click is disabled");
        return false;
    }
}
document.onmousedown = disableRightClick;
</script>


function DisableRightClick(event)
{
//For mouse right click
if (event.button==2)
{
alert("Right Clicking not allowed!");
}
}


这篇关于禁用右键单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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