常用的网页及js代码

禁止鼠标右键 

方法一:

<SCRIPT language=javascript> 
function click() 
{if (event.button==2) {alert("你好,欢迎光临!") }} 
document.onmousedown=click 
</SCRIPT>

补充说明: 
鼠标完全被封锁,可以屏蔽鼠标右键和网页文字。 
<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">

 

方法二:

oncontextmenu=return(false)    将彻底屏蔽鼠标右键
例如:
<table border oncontextmenu=return(false)><td>no</table> 可用于Table

取消选取、防止复制

onselectstart="return false"

例如:

<body onselectstart="return false">

 

不准粘贴

onpaste="return false"

例如:

<body onpaste="return false">

防止复制

oncontextmenu="window.event.returnvalue=false"

例如:

<body oncontextmenu="window.event.returnvalue=false">

 网页是否被检索

<meta name="ROBOTS" content="属性值">
  其中属性值有以下一些:
  属性值为"all": 文件将被检索,且页上链接可被查询;
  属性值为"none": 文件不被检索,而且不查询页上的链接;
  属性值为"index": 文件将被检索;
  属性值为"follow": 查询页上的链接;
  属性值为"noindex": 文件不检索,但可被查询链接;
  属性值为"nofollow": 文件不被检索,但可查询页上的链接。 

实现网页在规定时间内自动跳转的代码
<meta http-equiv="refresh" content="30;url=http://www.baidu.com">

电子邮件处理提交表单
<form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain"> 
<input type=submit>
</form>

判断上一页的来源
document.referrer

屏蔽功能键Shift,Alt,Ctrl

<script>
function look(){ 
if(event.shiftKey) 
alert("禁止按Shift键!"); //可以换成ALT CTRL

document.onkeydown=look; 
</script>

 

IE地址栏前换成自己的图标

 <link rel="Shortcut Icon" href="favicon.ico">

可以在收藏夹中显示出你的图标

 

<link rel="Bookmark" href="favicon.ico">

posted @ 2015-03-05 10:40  webnote  阅读(79)  评论(0编辑  收藏  举报