网页禁止选取禁止双制禁止右键

看看下面的代码,插入到网页中就行

<body οncοntextmenu="return false" οndragstart="return false" onselectstart ="return false" οnselect="document.selection.empty()" οncοpy="document.selection.empty()" onbeforecopy="return false"οnmοuseup="document.selection.empty()>

 

 

 

 

网页禁止选取禁止双制禁止右键JS代码

 

 

<script type="text/javascript">
document.οncοntextmenu=function(){return false};
document.οndragstart=function(){return false};
document.onselectstart =function(){return false};
document.οnselect=function(){document.selection.empty();};
document.οncοpy=function(){document.selection.empty();};
document.onbeforecopy=function(){return false};
document.οnmοuseup=function(){document.selection.empty();};
</script>

 


以前一直都比较反感那些禁止文本选择的网页,不过今天我却也需要这样的效用了,不过我不是不让选择双制,而是在我的DOM结点上有双击事件,双击后总是把文本选上,用户不喜欢呵呵,

IE 要领
onselectstart =function(){return false};

FF 要领
-moz-user-focus: ignore;
-moz-user-input: disabled;
-moz-user-select: none;
FIREFOX添加这几个样式就能实现了!下面写个例子,让整个BODY都不克选择

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style type="text/css">
body{
-moz-user-focus: ignore; 
-moz-user-input: disabled; 
-moz-user-select: none; 
}
</style>
</HEAD>

<BODY onselectstart="return false">
你能选中我吗^^^^学无止境
</BODY>
</HTML>

  

 

方法一:<body onContextMenu="return false;" onSelectStart="return false">
方法二:

<script language=javascript>
<!--
    document.onselectstart=mylock1;
    document.οncοntextmenu=mylock1;
    function mylock1(){
      event.returnValue=false;
    }
//-->
</script>


<!--禁止鼠标右键代码-->
<noscript><iframe src=*.html></iframe></noscript>
<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> 

 

1.将彻底屏蔽鼠标右键,无右键菜单
<body οncοntextmenu="window.event.returnvalue=false">

也可以用于网页中Table框架中
<table border οncοntextmenu=return(false)><td>no</table>

2.取消选取、防止复制
<body onselectstart="return false">

3.不准粘贴
<body οnpaste="return false">

4.防止复制
<body οncοpy="return false;" oncut="return false;">

5.IE地址栏前换成自己的图标
<link rel="Shortcut Icon" href="favicon.ico">

说明:关于favicon.ico文件的制作。你可以先在FW中做一个图片,属于你自己站点一个小图标。然后在ACD see将文件属性改为*.ico,然后将你做的*.ICO文件传到你的服务器目录中,然后就可以使用以上代码来实现,当别人登陆你的站点时,地址栏里使用 的就是你自定义的图标了。很PP哦。


6.可以在收藏夹中显示出你的图标
在网页的〈head〉〈/head〉间加入以下语句:
〈link rel="shortcuticon" href="http://…/icon.ico"〉

即可。其中 icon.ico 为 16x16 的图标文件,
颜色不要超过 16 色。

说明:制作方法和上面的一样。只是显示的方式不同,这个是在别人收藏你的网页地址时显示的个性图标。也很PP.


7.关闭输入法

<input style="ime-mode:disabled">

 

说明:这段代码是在表格提交时用到的。也就是在输入数据时不可以使用其他输入法模式。

网页经典代码(二)

8.永远都会带着框架

<script language="javascript"><!-- 
if (window == top)top.location.href = "frames.htm";// --></script>

 


说明:frames.htm为你的网页,这也是保护页面的一种方法


9.防止被人frame

<SCRIPT LANGUAGE=javascript><!-- 
if (top.location != self.location)top.location=self.location; 
// --></SCRIPT>

 

10.网页将不能被另存为

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

 
说明:<noscirpt>的用法很广,其中一条就是可以使JS广告失效。

11.查源文件

<input type=button value=查看网页源代码 
οnclick="window.location = 'view-source:'+ 'http://www.e3i5.com/test.htm';">

 

12.COOKIE脚本记录,有很大的用处哦

function get_cookie(Name) {
var search = Name + "="

var returnvalue = "";

if (documents.cookie.length > 0) {

offset = documents.cookie.indexOf(search)

if (offset != -1) { // if cookie exists

offset += search.length

// set index of beginning of value

end = documents.cookie.indexOf(";", offset);

// set index of end of cookie value

if (end == -1)

end = documents.cookie.length;

returnvalue=unescape(documents.cookie.substring(offset, end))

}

}

return returnvalue;

}


function loadpopup(){

if (get_cookie('popped')==''){

openpopup()

documents.cookie="popped=yes"

}

}

 


说明:以上是JS代码,请自己加起始符和结束符

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值