防止頁面內容的複製、選取和右鍵屏蔽

通過下面的代碼,即可實現頁面全屏蔽功能:

<DIV id=divTitle style="FONT-SIZE: 16px">禁止複製代碼1</DIV>
<SCRIPT LANGUAGE=javascript>
function click() {
alert('禁止你的左鍵複製!') }
function click1() {
if (event.button==2) {alert('禁止右鍵點擊~!') }}
function CtrlKeyDown(){
if (event.ctrlKey) {alert('不當的拷貝將損害您的系統!') }}
document.οnkeydοwn=CtrlKeyDown;
document.onselectstart=click;
document.οnmοusedοwn=click1;
</SCRIPT>



<SCRIPT language=javascript></SCRIPT>
<DIV id=divTitle style="FONT-SIZE: 16px">禁止複製代碼2</DIV>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; οnresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body leftmargin=0 topmargin=0 οnmοusemοve='HideMenu()' οncοntextmenu="return false" οndragstart="return false" onselectstart ="return false" οnselect="document.selection.empty()" οncοpy="document.selection.empty()" onbeforecopy="return false" οnmοuseup="document.selection.empty()">
<noscript><iframe src=*></iframe></noscript>

// 徹底屏蔽右鍵菜單
document.oncontextmenu = function()
{
window.event.returnvalue=false;
alert("對話框內容");
return false;
}

或者:
在<body>中加入以下代碼: 效果等價(我感覺還是加下面的好,多容易啊)
<body οnmοusemοve=/HideMenu()/ οncοntextmenu="return false" οndragstart="return false" onselectstart ="return false" οnselect="document.selection.empty()" οncοpy="document.selection.empty()" onbeforecopy="return false" οnmοuseup="document.selection.empty()"> 
 

發佈了34 篇原創文章 · 獲贊 8 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章