jianheng

本文转载来:canlynet的博客 记载自此希望自己能记住

1.body用如下方式:

<body oncontextmenu=\'return false\' ondragstart=\'return false\' onselectstart =\'return false\' onselect=\'document.selection.empty()\' oncopy=\'document.selection.empty()\' onbeforecopy=\'return false\' onmouseup=\'document.selection.empty()\'> 2.禁止用Ctrl+c复制,我们禁止Ctrl键:

<script type="text/javascript"> function DisableCopyKey()   {   if(event.keyCode==17)     document.selection.clear();   }   document.onkeydown=DisableCopyKey; </script>

3.由于firfox浏览器对body中onselectstart等动作不支持,所以需要用css的方法禁止。

<style type="text/css">

body {-moz-user-select: -moz-none;}

</style>

4.防止下载下来改源码再复制,在<body ........................>下一行添加:

<noscript><iframe src=*.html></iframe></noscript>

 

经过如上步骤,用户在ie和firefox中都无法选择文字,也就无法复制了。同时,也无法下载这个页面,这样一来,想要复制文字和图片,都不容易,除非浏览器有下载图片的功能,但文字肯定是无法复制了。

分类:

技术点:

相关文章: