免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
禁止右鍵代碼
禁止右鍵代碼
2006-10-29 14:14

有時(shí)自己辛苦半天做的網(wǎng)頁,尤其是一些javascript特效,很容易被人利用查看源文件而復(fù)制。那么如何才能防止被人查看源代碼呢?我們可以利用event.button特性來做到。下表是event.button屬性的可能取值及含義:
0 沒按鍵
1 按左鍵
2 按右鍵
3 按左和右鍵
4 按中間鍵
5 按左和中間鍵
6 按右和中間鍵
7 按所有的鍵
參照上表,我們可以在<body>和</body>之間加入如下語句:
<Script Langvage=javascript>
function Click(){
if (event.button!=1){alert(‘版權(quán)所有(C)2001 XXX工作室‘);
}}
document.onmousedown=Click;
</Script>
這樣在瀏覽網(wǎng)頁時(shí)除單擊鼠標(biāo)左鍵外,其他任何形式的鼠標(biāo)點(diǎn)擊或組合點(diǎn)擊,都將出現(xiàn)“版權(quán)所有(C)2001 XXX工作室”的提示框,而不是出現(xiàn)快捷菜單,從而避免被人查看源文件代碼。
如果使event.button=2,實(shí)際上它僅能限制點(diǎn)擊鼠標(biāo)右鍵情況,其他點(diǎn)擊方式,如按左右鍵、按左和中間鍵、按中間鍵等就不能限制,當(dāng)這些方式的點(diǎn)擊發(fā)生時(shí),出現(xiàn)的就是快捷菜單,從而可以查看源文件。    

注意:把body改為如下代碼:<body oncontextmenu="window.event.returnValue=false">,其中Value中的V一定要大寫!!

頁面禁用鼠標(biāo)右鍵代碼

可以把下面代碼加入到頁面適當(dāng)位置。
LeadBBS論壇應(yīng)用下面代碼時(shí),可以打開:inc/Board_Popfun.asp文件
查找:
<script language = "JavaScript" src = "<%=DEF_BBS_HomeUrl%>inc/JF.js" type="text/javascript"></script>
下面加入代碼。

<script language=javascript>
function openScript(url, width, height,left,top,r){
     var Win = window.open(url,"openScript",‘width=‘ + width + ‘,height=‘ + height + ‘,left=‘ +left+ ‘,top=‘+top+‘,resizable=no,scrollbars=‘+r+‘,menubar=no,status=no‘ );
}

//以下為禁止鼠標(biāo)右鍵的代碼,不想禁止的可以刪除
<!--

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) {alert("【E路極速】歡迎你"); } }
{
event.cancelBubble = true
event.returnValue = false;
return false;
}

}

document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
//-->
</script>
 
圖片禁用鼠標(biāo)右鍵代碼

應(yīng)用方法同上。

<script language="JavaScript1.2">
var clickmessage="本站圖片禁用右鍵!"
function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
}

function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

if (document.all)
document.onmousedown=disableclick
else if (document.layers)
associateimages()
</script>


功能:禁止右鍵、禁選擇、禁粘貼、禁shift、禁ctrl、禁alt

<script language="JavaScript">
<!--
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.onmousedown = norightclick;  // for all others
//-->
</script>

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

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
鼠標(biāo)特效——禁止復(fù)制網(wǎng)頁代碼
禁止網(wǎng)頁復(fù)制的代碼
如何在文章中添加MID格式的背景音樂
禁用鼠標(biāo)右擊事件
防止網(wǎng)頁圖片被復(fù)制代碼
網(wǎng)頁防盜代碼
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服