日期:2014-05-16  浏览次数:20418 次

JavaScript常用小技巧—各种屏蔽功能
1 屏蔽弹出窗口最大化按钮
代码如下:
<script language="Javascript">
<!-- script begins here by POPOEVER
function alwaysRaised() {
var newWindow = window.open("http://andrepan.topcool.net/index.html","","Height=400,Width=300,alwaysRaised");
}
//-->
</script>
2 禁止点击鼠标右键
<script language="javascript">
function click() {
if (event.button==2) {
alert('对不起,本页的内容不经允许不得拷备。')
}
}
document.onmousedown=click
</script>

3 彻底屏蔽鼠标右键
oncontextmenu="window.event.returnValue=false"
<table border oncontextmenu=return(false)><td>no</table> 可用于Table

4 屏蔽ctrl+N功能
<body onkeydown='if(event.keyCode==78&&event.ctrlKey)return false;'>

5 网页文字不被选中
<HTML>
<body onselectstart="return false">
无忧脚本<br>无忧脚本<br>无忧脚本<br>无忧脚本<br>无忧脚本<br>无忧脚本<br>无忧脚本</body>
</html>

6 不准粘贴
onpaste="return false"

7 防止复制
oncopy="return false;" oncut="return false;"

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

9 在收藏夹中显示出自己的图标
<link rel="Bookmark" href="favicon.ico">

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

11 防止被人frame
<SCRIPT LANGUAGE=JAVASCRIPT><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>

12 防止网页另存为
<html>
<noscript><iframe src=*.html></iframe></noscript>
<body >
</body>
</html>

13 屏蔽功能键Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift键!"); //可以换成ALT CTRL
}
document.onkeydown=look;
</script>

14 网页不会被缓存
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">

15 不要滚动条
让竖条没有:
<body style="overflow:scroll;overflow-y:hidden">
</body>
让横条没有:
<body style="overflow:scroll;overflow-x:hidden">
</body>
两个都去掉?更简单了
<body scroll="no">
</body>

16 去掉图片链接点击后,图片周围的虚线
<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>

17 在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
<STYLE>
body
{background-image:url(logo.gif); background-repeat:no-repeat;

background-position:center;background-attachment: fixed}
</STYLE>

18 脚本永不出错
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>

19 屏蔽网页上的所有按键
<html>
<head>
</head>
<body leftmargin=0 topmargin=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()">
</body>
</html>

source   http://lib.360doc.com/06/0117/11/344_59490.shtml

?