拽拽
管理员组

js 禁止html网站页面鼠标右键复制代码示例

禁止右键代码

<script language="JavaScript">

<!--


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>

禁止复制代码

<script>

function disableselect(e){

return false}

function reEnable(){return true

}

file://if IE4+

document.onselectstart=new Function ("return false")

file://if NS6

if (window.sidebar){

document.onmousedown=disableselect

document.onclick=reEnable

}

</script>

<script>

<!--

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; onresize=MM_reloadPage; }}

    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);

//-->

</script>


#1楼
发帖时间:2015-9-15   |   查看数:0   |   回复数:0
游客组