1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
d]6#pSE <table border oncontextmenu=return(false)><td>no</table> 可用于Table
Ho; bgva 2E":6:Wsw 2. <body onselectstart="return false"> 取消选取、防止复制
m@){@i2. <ny)yK 3. onpaste="return false" 不准粘贴
eDPmUlC+- Gv3AJ'NL 4. oncopy="return false;" oncut="return false;" 防止复制
+kK6G#c I6E!$} 5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标
1Xi.OGl zn@yt%PCV 6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标
+(|6Wv g$j ZpU 7. <input style="ime-mode:-Disabled"> 关闭输入法
E}WO?xxv74 D~s
TQfWr 8. 永远都会带着框架
CAl]Kpc <script language="javascript"><!--
RIO4`, if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
5==}8<$ // --></script>
+Ks! 9d*k< ,[{)4J$MV 9. 防止被人frame
y.:Z:w6$ <SCRIPT LANGUAGE=javascript><!--
%!i|"FNc if (top.location != self.location)top.location=self.location;
EecV%E // --></SCRIPT>
fmhqm" x)<Hr,wd 10. 网页将不能被另存为
R~R ?0aq <noscript><iframe src=*.html></iframe></noscript>
KLn.vA. ;{k`nv_6 11. <input type=button value=查看网页源代码
8XUm.nV onclick="window.location = `view-source:`+
http://www.51js.com/`";>
N=oWIK<;- `:I<Jp 12.删除时确认
c$>$2[*= <a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删
pjP
R3
r XeT{y]lkd 除</a>
jw"]U jub 3 O)^Hq+9 13. 取得控件的绝对位置
c)tG1|Og] //javascript
#, KjJ <script language="javascript">
71# ipZ function getIE(E){
Cd"iaiTD0 var t=e.offsetTop;
cj!Ew}o40D var l=e.offsetLeft;
g}B|ZRz+{ while(e=e.offsetParent){
Do&/+Ssnu t+=e.offsetTop;
PnKgUJoa0 l+=e.offsetLeft;
&~xzp^& }
Tl9;KE| alert("top="+t+"/nleft="+l);
UpU2H4 }
*"pf3x6 </script>
#H@rb ~X`_g/5X //VBScript
@l:o0(!W <script language="VBScript"><!--
JPt=~e( function getIE()
18AKM dim t,l,a,b
dSkW[r9Z%l set a=document.all.img1
E?z~)0z2` t=document.all.img1.offsetTop
}smPP* l=document.all.img1.offsetLeft
h8Bs=T while a.tagName<>"BODY"
i.e1?Zk1 set a = a.offsetParent
;=FSpZ@ t=t+a.offsetTop
Yc,qXK- l=l+a.offsetLeft
B7fV_-p: G wend
}?
W[D msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
8a^E{x@HT end function
5Cp6$V|/kv --></script>
$dp;$X3 .ZB(!v/2 14. 光标是停在文本框文字的最后
k yFq <script language="javascript">
R4V~+tnbG& function cc()
v?U;o&L(
{
xSQ:#o=8G var e = event.srcElement;
i'$V'x'k var r =e.createTextRange();
{v,O r.moveStart(`character`,e.value.length);
ue5C
] r.collapse(true);
s5DEuu>g r.select();
V4PV@{G }
v^=Po6S[{+ </script>
)\bA'LuFy <input type=text name=text1 value="123" onfocus="cc()">
[LQD]# g.3a5#t 15. 判断上一页的来源
.<<RI8A javascript:
cF[L6{Oe document.referrer
FC:+[.fi DRn]>IFU 16. 最小化、最大化、关闭窗口
IwfJDJJ <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
8<Y*@1*j <param name="Command" value="Minimize"></object>
PE IUKlX <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
ya<nD '%9 <param name="Command" value="Maximize"></object>
z)RJUmY3B <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<QUjhWxDb <PARAM NAME="Command" value="Close"></OBJECT>
+ti_?gfx }W:Rg}v <input type=button value=最小化 onclick=hh1.Click()>
@MS}tZ5 <input type=button value=最大化 onclick=hh2.Click()>
SpM|b5c5 <input type=button value=关闭 onclick=hh3.Click()>
atW=xn 本例适用于IE
UkE fuH !&$uq|- 17.屏蔽功能键Shift,Alt,Ctrl
(^:0g.~c <script>
\lJCBb+k function look(){
/YP,Wfd% if(event.shiftKey)
[f^:V:){ alert("禁止按Shift键!"; //可以换成ALT CTRL
g9A8b(>F&@ }
6`tc]a"#Zb document.onkeydown=look;
@2LpI*]C </script>
s\)0f_I 6%hr]>L 18. 网页不会被缓存
7wivu*0 <META HTTP-EQUIV="pragma" CONTENT="no-cache">
Y;X_E7U <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
m5wfQ_}}ss <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
y h
或者<META HTTP-EQUIV="expires" CONTENT="0">
(Q_J{[F fd {75J5% 19.怎样让表单没有凹凸感?
\; 9log<Z <input type=text style="border:1 solid #000000">
,eI2#6w|C 或
3y[6n$U& <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:
XB8g5AxR ^dR="N 1 solid #000000"></textarea>
C#^V<:9 B1x# 7>K 20.<div><span>&<layer>的区别?
=N62 ){{ <div>(division)用来定义大段的页面元素,会产生转行
9vQI
~rz? <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
lo1<t<w` <layer>是ns的标记,ie不支持,相当于<div>
D#=$? {w }#u.Of`6" 21.让弹出窗口总是在最上面:
X=8CZq4 <body onblur="this.focus();">
!CBvFl/v \gBsAZE 22.不要滚动条?
U?bQBHIC 让竖条没有:
*{t]fds <body style=`overflow:-Scroll;overflow-y:hidden`>
Ix-bJE6+I, </body>
>FVBn;1 让横条没有:
eucacXiZ <body style=`overflow:-Scroll;overflow-x:hidden`>
N(6Q`zs </body>
#-]!;sY> 两个都去掉?更简单了
:>:F6Db"U <body scroll="no">
sew0n`d1 </body>
v%ldg833l 6n|R<DO%\ 23.怎样去掉图片链接点击后,图片周围的虚线?
HX;JO[0 <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
b"DV8fdX | 61W-9; 24.电子邮件处理提交表单
5f~49(v] <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
}{R?i,j( <input type=submit>
I"=a:q </form>
c#ahFpsnlw $?HOke 25.在打开的子窗口刷新父窗口的代码里如何写?
n A<#A window.opener.location.reload()
?M}W;Z jkVX>*.|oy 26.如何设定打开页面的大小
_d[4EY <body onload="top.resizeTo(300,200);">
_Q**4 打开页面的位置<body onload="top.moveBy(300,200);">
\>DMN # U,tl)(!@Q- 27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
bAUruTn <style>
O`;e^PhN body
[Yq*DkW {background-image:url(logo.gif); background-repeat:no-repeat;
#OQT@uF! fEWXC|" background-position:center;background-attachment: fixed}
j3Sz+kOf, </style>
Z[,A>tJ kBRy(?Mft& 28. 检查一段字符串是否全由数字组成
JO3x#1~;_ <script language="javascript"><!--
qg`8f? function checkNum(str){return str.match(//D/)==null}
SHAC(3o/e alert(checkNum("1232142141"
Rk8oshS+2 alert(checkNum("123214214a1"
QY^v*+lr\ // --></script>
S [$Os7 3pk=c-x 29. 获得一个窗口的大小
.|VWYN document.body.clientWidth; document.body.clientHeight
Knjg`f 3axbWf3[ 30. 怎么判断是否是字符
DjMhI_Yu if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
]c+HD* else alert("全是字符";
r(VGdG Ft[)m#Dj` 31.TEXTAREA自适应文字行数的多少
sTb@nrRxH <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
38gHM9T
xh </textarea>