如何禁止複製網頁內容?(javascript)

來源:互聯網
上載者:User

用JAVA禁止複製網頁內容

<Script Language=javascript>
function key(){

//if(event.shiftKey){
//window.close();}
//禁止shift
if(event.altKey){
alert('禁止CTRL-C複製本貼內容');}
//禁止alt
if(event.ctrlKey){
alert('禁止CTRL-C複製本貼內容');}
//禁止ctrl
return
false;}
document.onkeydown=key;
if
(window.Event)
document.captureEvents(Event.MOUSEUP);
//swordmaple
javascript article.
//from www.jx165.com
//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;}
}
function Click(){
alert('禁止右鍵粘貼本貼內容');

window.event.returnValue=false;
}
document.oncontextmenu=Click;

</Script>

一個更簡單的方法就是在<body>中加入如下的代碼,這樣滑鼠的左右鍵都失效了.

topmargin="0"
oncontextmenu="return false" ondragstart="return false" onselectstart ="return
false" onselect="document.selection.empty()" oncopy="document.selection.empty()"
onbeforecopy="return false"
onmouseup="document.selection.empty()"

1.禁止網頁另存新檔:在<body>後面加入以下代碼:
<noscript>
<iframe
src="*.htm"></iframe>
</noscript>

2.禁止網頁內容複寫.粘貼:在<body>中加入以下代碼:
<body
onmousemove=\HideMenu()\ oncontextmenu="return false" ondragstart="return false"
onselectstart ="return false" onselect="document.selection.empty()"
oncopy="document.selection.empty()" onbeforecopy="return false"
onmouseup="document.selection.empty()">

 

用JAVA禁止複製網頁內容

<Script Language=javascript>
function key(){

//if(event.shiftKey){
//window.close();}
//禁止shift
if(event.altKey){
alert('禁止CTRL-C複製本貼內容');}
//禁止alt
if(event.ctrlKey){
alert('禁止CTRL-C複製本貼內容');}
//禁止ctrl
return
false;}
document.onkeydown=key;
if
(window.Event)
document.captureEvents(Event.MOUSEUP);
//swordmaple
javascript article.
//from www.jx165.com
//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;}
}
function Click(){
alert('禁止右鍵粘貼本貼內容');

window.event.returnValue=false;
}
document.oncontextmenu=Click;

</Script>

一個更簡單的方法就是在<body>中加入如下的代碼,這樣滑鼠的左右鍵都失效了.

topmargin="0"
oncontextmenu="return false" ondragstart="return false" onselectstart ="return
false" onselect="document.selection.empty()" oncopy="document.selection.empty()"
onbeforecopy="return false"
onmouseup="document.selection.empty()"

1.禁止網頁另存新檔:在<body>後面加入以下代碼:
<noscript>
<iframe
src="*.htm"></iframe>
</noscript>

2.禁止網頁內容複寫.粘貼:在<body>中加入以下代碼:
<body
onmousemove=\HideMenu()\ oncontextmenu="return false" ondragstart="return false"
onselectstart ="return false" onselect="document.selection.empty()"
oncopy="document.selection.empty()" onbeforecopy="return false"
onmouseup="document.selection.empty()">

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.