我想在silverlight中禁用html查看器上的右键单击选项。可以避免在silverlight页面上单击右键,但是当我右键单击html查看器时,我得到右键单击选项。我不想要正确的单击 html 查看器中的选项。任何人都可以帮助我解决这个问题。
问问题
446 次
1 回答
0
看看这段代码 -
<SCRIPT language=JavaScript>
<!-- http://www.spacegun.co.uk -->
var message = "function disabled";
function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){ alert(message); return false; }
if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; } }
document.onmousedown = rtclickcheck;
</SCRIPT>
还有这个例子:
<SCRIPT TYPE="text/javascript">
<!--
//Disable right click script
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</SCRIPT>
取自帖子:
http://rainbow.arch.scriptmania.com/scripts/no_right_click.html
于 2012-04-23T08:56:50.953 回答