设计在线

网站网页怎么防左键,防右健点击复制

发布制作:admin  发布日期:2013/1/31

现在很多企业网站建设的客户要求网页中的内容,图片不能被轻易复制下来,也就是防左键选中,防右键操作,以次来保护自己网站的信息尽可能少的被别人盗用.

禁止复制代码

方法一:(比较简单、推荐使用)
<script language="JavaScript">
document.oncontextmenu=new Function("event.returnValue=false;");
document.onselectstart=new Function("event.returnValue=false;");
</script>
方法二:
<SCRIPT LANGUAGE=javascript>
function click() {
alert('禁止你的左键复制!') }
function click1() {
if (event.button==2) {alert('禁止右键点击~!') }}
function CtrlKeyDown(){
if (event.ctrlKey) {alert('不当的拷贝将损害您的系统!') }}
document.onkeydown=CtrlKeyDown;
document.onselectstart=click;
document.onmousedown=click1;
</SCRIPT>
方法三:
禁止复制代码2
<script language="JavaScript" type="text/JavaScript">
<!--
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>
</head>
<body leftmargin=0 topmargin=0 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()">
<noscript><iframe src=*></iframe></noscript>

使用方法:把代码插入到模板文件中模板文件夹在/templets/default/ 如果是首页禁止复制就插入到index.htm 的<body></body>中就可以了