js禁止右键、复制、粘贴、另存为等功能代码_蓝戒的博客


js禁止右键、复制、粘贴、另存为等功能代码

1、对整个网页限制鼠标右键:

oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键,其实是禁止快捷菜单,因为不光右键可以弹出这个菜单,键盘上空格键右边的windows键也可以激活这个快捷菜单。

<table border oncontextmenu=return(false)> <td> no</table> 可用于Table
function click() {
if (event.button==2) {
alert('对不起,本页禁用右键!')
}
}
document.onmousedown=click

2禁止鼠标右键:oncontextmenu="return false";

3禁止选择:onselectstart="return false";  <body onselectstart="return false"> 整个网页禁止选取、防止复制

4禁止拖放:ondragstart="return false";

5禁止拷贝:oncopy=document.selection.empty() 。

6禁止复制和剪切:oncopy="return false;" oncut="return false;"

7禁止保存:<noscript><iframe src="*.htm"></iframe></noscript>,放在head里面。

8、禁止粘贴:<input type=text onpaste="return false">

9关闭输入法:<input style="ime-mode:disabled">

10屏蔽打印:

<style>

@media print{

* {display:none}

} </style>

11禁止查看源文件:

<html>
<head>
<script>
function clear(){
Source=document.body.firstChild.data;
document.open();
document.close();
document.title=”看不到源代码”;
document.body.innerHTML=Source;
}

clear();

</script>

12图片禁止右键保存:

把下面代码放在<head>和</head>之间
<script >
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>

</head>

13网页禁止另存为: 

<noscript><iframe src=”/blog/*.html>”;</iframe></noscript>

禁止被frame调用:

<script >if (top.location != self.location)top.location=self.location;</script>

14禁shift、禁ctrl、禁alt

<script>
function key(){
if(event.shiftKey){
window.close();}
//禁止Shift
if(event.altKey){
window.close();}
//禁止Alt
if(event.ctrlKey){
window.close();}
//禁止Ctrl
return false;}
document.onkeydown=key;
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
key();
</script>

参考资料:

1、http://www.oschina.net/code/snippet_262017_19272

2、http://www.jb51.net/article/23077.htm

3、http://www.ithao123.cn/content-8054668.html

4、http://www.chhua.com/web-note2825

5、http://blog.csdn.net/yj451928923/article/details/7094628

本文固定链接: http://www.webzsky.com/?p=779 | 蓝戒的博客

cywcd
该日志由 cywcd 于2016年01月01日发表在 javascript 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: js禁止右键、复制、粘贴、另存为等功能代码 | 蓝戒的博客

js禁止右键、复制、粘贴、另存为等功能代码:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter
来自的朋友,欢迎您 点击这里 订阅我的博客 o(∩_∩)o~~~
×