网页中最常用的JS代码(js禁止右键、禁止复制)
2016-12-12 19:57
441 查看
第一种也是简单的添加事件:
【【<body oncopy="returnfalse"> 禁止复制
<input type=""name=""id=""value=""onpaste="returnfalse"/>
禁止粘贴
<body onselectstart="return false "> 禁止被选中。】】】】】】
以下是转载。:
<body oncontextmenu=”return false”></body>
<!– 禁用右键: –>
<script>
function stop(){
return false;
}
document.oncontextmenu=stop;
</script>
<body onselectstart=”return false”> 取消选取、防止复制
oncopy=”return false;” oncut=”return false;” 防止复制
四:禁止查看源文件
<html>
<head>
<script>
function clear(){
Source=document.body.firstChild.data;
document.open();
document.close();
document.title=”看不到源代码”;
document.body.innerHTML=Source;
}</script>
</head>
五、图片下载限制
<script language=”javascript”>
function Click(){
if(window.event.srcElement.tagName==”IMG”)
{
alert(‘图片直接右键’);
window.event.returnValue=false;
}
}
document.oncontextmenu=Click;
</script>
<META HTTP-EQUIV=”imagetoolbar” CONTENT=”no”>
插入图片时加入galleryimg属性
<img galleryimg=”no” src=””>
禁止右键保存
把下面代码放在<head>和</head>之间
<SCRIPT LANGUAGE=java 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>
方式二:
在页面中加入如下js代码:原理:屏蔽右键
<script>
function document.onmousedown()
{
if(event.button==2||event.button==3)
{
alert( “右健被禁止 “)
return false
}
}
</script>
网页防复制代码 禁止查看网页源文件代码
插入网页即可。
<body leftmargin=”2″ topmargin=”0″ marginwidth=”0″ marginheight=”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()”>
<noscript><iframe src=”/blog/*>”;</iframe></noscript>
1. oncontextmenu=”window.event.returnvalue=false” //将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> //可用于Table
——————————————————————————————–
———-
2. <body onselectstart=”return false”> //取消选取、防止复制
——————————————————————————————–
———-
3. onpaste=”return false” //不准粘贴
——————————————————————————————–
———-
4. oncopy=”return false;” oncut=”return false;” // 防止复制
——————————————————————————————–
———-
5. //防止被人frame
<SCRIPT LANGUAGE=javascript><!–
if (top.location != self.location)top.location=self.location;
// –></SCRIPT>
——————————————————————————————–
———-
6. <noscript><iframe src=”/blog/*.html>”;</iframe></noscript> //网页将不能被另存为
——————————————————————————————–
———-
7. //改变连接是状态栏的显示内容
〈a href=”http://v.2best.cc” onMo … ;window.status=’输入连接状态栏显示内容’;return true”>
——————————————————————————————–
———-
8. //禁止网页中目标对象被下载(如图片)
下面的代码将帮助你禁止网页中目标对象被下载:
<a href=”javascript:void(0)” onMouseDown=”alert(‘对不起!图片不能下载!’)”>
</a>
——————————————————————————————–
———-
9. //页面禁止刷新完全
最好在pop出来的窗口里用,没工具栏的
<body onkeydown=”KeyDown()” onbeforeunload=”location=location”
oncontextmenu=”event.returnValue=false”>
<script language=”Javascript”><!–
function KeyDown(){
if ((window.event.altKey)&&
((window.event.keyCode==37)||
(window.event.keyCode==39))){ alert(“请访问我的主页”);
event.returnValue=false;
}
if ((event.keyCode==8)|| (event.keyCode==116)){ //屏蔽 F5 刷新键
event.keyCode=0;
event.returnValue=false;
}
if ((event.ctrlKey)&&(event.keyCode==78)){ //屏蔽 Ctrl+n
event.returnValue=false;
}
if ((event.shiftKey)&&(event.keyCode==121)){ //屏蔽 shift+F10
event.returnValue=false;
}
}
</script>
</body
转载自WEB开发笔记 www.chhua.com
【【<body oncopy="returnfalse"> 禁止复制
<input type=""name=""id=""value=""onpaste="returnfalse"/>
禁止粘贴
<body onselectstart="return false "> 禁止被选中。】】】】】】
以下是转载。:
<body oncontextmenu=”return false”></body>
<!– 禁用右键: –>
<script>
function stop(){
return false;
}
document.oncontextmenu=stop;
</script>
<body onselectstart=”return false”> 取消选取、防止复制
oncopy=”return false;” oncut=”return false;” 防止复制
四:禁止查看源文件
<html>
<head>
<script>
function clear(){
Source=document.body.firstChild.data;
document.open();
document.close();
document.title=”看不到源代码”;
document.body.innerHTML=Source;
}</script>
</head>
五、图片下载限制
<script language=”javascript”>
function Click(){
if(window.event.srcElement.tagName==”IMG”)
{
alert(‘图片直接右键’);
window.event.returnValue=false;
}
}
document.oncontextmenu=Click;
</script>
<META HTTP-EQUIV=”imagetoolbar” CONTENT=”no”>
插入图片时加入galleryimg属性
<img galleryimg=”no” src=””>
禁止右键保存
把下面代码放在<head>和</head>之间
<SCRIPT LANGUAGE=java 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>
方式二:
在页面中加入如下js代码:原理:屏蔽右键
<script>
function document.onmousedown()
{
if(event.button==2||event.button==3)
{
alert( “右健被禁止 “)
return false
}
}
</script>
网页防复制代码 禁止查看网页源文件代码
插入网页即可。
<body leftmargin=”2″ topmargin=”0″ marginwidth=”0″ marginheight=”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()”>
<noscript><iframe src=”/blog/*>”;</iframe></noscript>
1. oncontextmenu=”window.event.returnvalue=false” //将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> //可用于Table
——————————————————————————————–
———-
2. <body onselectstart=”return false”> //取消选取、防止复制
——————————————————————————————–
———-
3. onpaste=”return false” //不准粘贴
——————————————————————————————–
———-
4. oncopy=”return false;” oncut=”return false;” // 防止复制
——————————————————————————————–
———-
5. //防止被人frame
<SCRIPT LANGUAGE=javascript><!–
if (top.location != self.location)top.location=self.location;
// –></SCRIPT>
——————————————————————————————–
———-
6. <noscript><iframe src=”/blog/*.html>”;</iframe></noscript> //网页将不能被另存为
——————————————————————————————–
———-
7. //改变连接是状态栏的显示内容
〈a href=”http://v.2best.cc” onMo … ;window.status=’输入连接状态栏显示内容’;return true”>
——————————————————————————————–
———-
8. //禁止网页中目标对象被下载(如图片)
下面的代码将帮助你禁止网页中目标对象被下载:
<a href=”javascript:void(0)” onMouseDown=”alert(‘对不起!图片不能下载!’)”>
</a>
——————————————————————————————–
———-
9. //页面禁止刷新完全
最好在pop出来的窗口里用,没工具栏的
<body onkeydown=”KeyDown()” onbeforeunload=”location=location”
oncontextmenu=”event.returnValue=false”>
<script language=”Javascript”><!–
function KeyDown(){
if ((window.event.altKey)&&
((window.event.keyCode==37)||
(window.event.keyCode==39))){ alert(“请访问我的主页”);
event.returnValue=false;
}
if ((event.keyCode==8)|| (event.keyCode==116)){ //屏蔽 F5 刷新键
event.keyCode=0;
event.returnValue=false;
}
if ((event.ctrlKey)&&(event.keyCode==78)){ //屏蔽 Ctrl+n
event.returnValue=false;
}
if ((event.shiftKey)&&(event.keyCode==121)){ //屏蔽 shift+F10
event.returnValue=false;
}
}
</script>
</body
转载自WEB开发笔记 www.chhua.com
相关文章推荐
- 网页中最常用的JS代码(js禁止右键、禁止复制)
- 链接到 网页中最常用的JS代码(js禁止右键、禁止复制)
- 链接到 网页中最常用的JS代码(js禁止右键、禁止复制)
- Js实现网页禁止右键菜单与防止复制内容另存网页
- javascript中几个有意思的功能(目前5项) 1右键无效 2禁止网页复制 3禁止F5刷新 4新发现 5屏蔽js错误
- 禁止右键,禁止选中,禁止网页复制的Js代码
- js网页禁止复制-禁止另存为-禁止选择-禁止鼠标右键代码
- js代码禁止网页文字复制!!禁止右键点击。
- 网页防复制,禁止文字选中,禁止右键菜单js代码,兼容大部分浏览器方法
- 禁止右键,禁止选中,禁止网页复制的Js代码
- js如何禁止网页复制和右键
- js网页禁止复制-禁止另存为-禁止选择-禁止鼠标右键代码
- 禁止网页内容复制、选取、禁止右键菜单js代码
- js代码禁止网页文字复制!!禁止右键点击。
- js禁止右键,复制,粘贴,选择
- Js禁止右键、禁止选中、禁止复制
- js+css实现禁止鼠标右键与选中网页文字
- 禁止右键、Ctrl键和复制功能的JS代码
- 保护自己的源码js禁止右键和复制(Ctrl+C)
- js禁止右键,禁止选取,禁止粘贴, 禁止复制,禁止剪贴