亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JavaScript代碼實現禁止右鍵、禁選擇、禁粘貼、禁shift、禁ctrl、禁alt

 更新時間:2015年11月17日 09:11:03   投稿:mrr  
這篇文章主要介紹了JavaScript代碼實現禁止右鍵、禁選擇、禁粘貼、禁shift、禁ctrl、禁alt,需要的朋友可以參考下

廢話不多說了直接給大家貼代碼了。

代碼如下:

<script language="JavaScript">
<!--
//js禁用某些鍵的代碼
//chabaoo.cn
function key(){ 
if(event.shiftKey){
window.close();}
//禁止Shift
if(event.altKey){
window.close();}
//禁止Alt
if(event.ctrlKey){
window.close();}
//禁止Ctrl
return false;}
document.onkeydown=key;
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu(){
event.cancelBubble = true
event.returnValue = false;
return false;}
function norightclick(e){
if (window.Event){
if (e.which == 2 || e.which == 3)
return false;}
else
if (event.button == 2 || event.button == 3){
event.cancelBubble = true
event.returnValue = false;
return false;}
}
//禁右鍵
document.oncontextmenu = nocontextmenu; // for IE5+
document.onmou<a href="http://chabaoo.cn/article/1141.html" target="_blank" class="infotextkey">sed</a>own = norightclick; // for all others
//-->
</script>

<body onselectstart="return false"; onpaste="return false";>

1. oncontextmenu="window.event.returnValue=false" 將徹底屏蔽鼠標右鍵特效
<table border oncontextmenu=return(false)><td>no</table> 可用于Table

2. <body onselectstart="return false"> 取消選取、防止復制

3. onpaste="return false" 不準粘貼

4. oncopy="return false;" oncut="return false;" 防止復制

PS:JS防止后退,刷新,關閉的解決辦法

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title> New Document </title>
</head>
<script language="javascript">
function RunOnBeforeUnload() {window.onbeforeunload = function(){ return '將丟失未保存的數據!'; } }
</script>
<body onload="RunOnBeforeUnload()">
刷新,關閉,后退,F5 測試
</body>
</html>

雖然onbeforeunload這個事件已經Web標準被淘汰,但目前能實現這個效果的也就只有這個事件.還好瀏覽器都能很好的支持.

測試結果:

IE6.0,FireFox,Chrome通過

相關文章

最新評論