網頁禁止複製

今天遇到了客戶要求網頁不可複製的要求,在百度中尋找,獲得以下答案,很是好,隨記下來

  很是感謝網絡中各位大神的分享,也願可以傳播這種精神javascript



用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.XXXX.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()">
相關文章
相關標籤/搜索