JavaScript防止複製,屏蔽滑鼠右鍵等常用實用技巧

來源:互聯網
上載者:User

1. 將徹底屏蔽滑鼠右鍵

oncontextmenu="window.event.returnValue=false"
<TABLE oncontextmenu=return(false) border=1>
<TBODY>
<TR>
<TD>no</TD></TR></TBODY></TABLE>可用於Table

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

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

4. 防止複製
<body leftmargin=0 topmargin=0 oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false' &#111nmouseup='document.selection.empty()'>

5. IE地址欄前換成自己的表徵圖
<LINK href="favicon.ico" rel="Shortcut Icon">

6. 可以在收藏夾中顯示出你的表徵圖
<LINK href="favicon.ico" rel=Bookmark> 7、防滑鼠右擊代碼
<SCRIPT language=JavaScript>
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
</SCRIPT>

8.指令碼永不出錯
<SCRIPT LANGUAGE="javascript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>

9. 關閉IME
<INPUT style="IME-MODE: disabled">

10. 永遠都會帶著架構
<SCRIPT language=JavaScript><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm為框架頁
// -->
</SCRIPT>

<!--<BR>if (window == top)top.location.href = "frames.htm"; //frames.htm為框架頁<BR>// -->
11. 防止被人frame
<SCRIPT language=JAVASCRIPT><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
<!-- <BR>if (top.location != self.location)top.location=self.location;<BR>// -->

12. 網頁將不能被另存新檔
<NOSCRIPT><IFRAME src="*.html"></IFRAME></IFRAME></NOSCRIPT>

13. 查看網頁原始碼
<INPUT type=button value=查看網頁原始碼 onclick="window.location = "view-source:"+ "http://www.mywebtd.cn">

14.刪除時確認
<A href="javascript:if(confirm(" 確實要刪除嗎??))location="boos.asp?&areyou=刪除&page=1" ?>刪除</A>

15. 取得控制項的絕對位置
//Javascript
<SCRIPT language=Javascript>
function getIE(e){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}<BR>
alert("top="+t+"/nleft="+l);
}
</SCRIPT>
//VBScript
<SCRIPT language=VBScript><!--
function getIE()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while a.tagName<>"BODY"
set a = a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend<BR>msgbox "top="&t&chr(13)&"left="&l,64,"得到控制項的位置"
end function
--></SCRIPT>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.