1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
6>ZUx}vYj <table border oncontextmenu=return(false)><td>no</table> 可用于Table
Mw2?U>h1 es@_6ol.@ 2. <body onselectstart="return false"> 取消选取、防止复制
6r/NdI \D(6t!Ox 3. onpaste="return false" 不准粘贴
az@{O4 U.<';fKnT 4. oncopy="return false;" oncut="return false;" 防止复制
!_rAAY /v"u4Ipj 5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标
u9rlNmf$ _hyboQi 6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标
{s!DRc]ln ZKTOif} 7. <input style="ime-mode:-Disabled"> 关闭输入法
UA$
XjP n5dFp%k 8. 永远都会带着框架
O,6Upk <script language="javascript"><!--
1lZl10M:f if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
N%!8 I // --></script>
mh;<lW\K/Z b[,J-/;JNL 9. 防止被人frame
y&Sl#IQ L <SCRIPT LANGUAGE=javascript><!--
mDz{8N9<FG if (top.location != self.location)top.location=self.location;
Iih~W& // --></SCRIPT>
[<P(S~J P3se"pP 10. 网页将不能被另存为
f3Ior.n( <noscript><iframe src=*.html></iframe></noscript>
P.mz$M \G}EI|Wo 11. <input type=button value=查看网页源代码
V.5gxr3QqW onclick="window.location = `view-source:`+
http://www.51js.com/`";>
d{2+>
>d 1P(rgn:8e 12.删除时确认
9X&Xc <a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删
&1Dq3%$c @ qWgokf 除</a>
r#
MJ tr0P;}= 13. 取得控件的绝对位置
_cdrz)T //javascript
+@[T0cXp <script language="javascript">
ScU?T<u:i function getIE(E){
W|J8QNL?jm var t=e.offsetTop;
'EoJo9p6} var l=e.offsetLeft;
:4s{?IY)l while(e=e.offsetParent){
:GXiA t+=e.offsetTop;
?.E6Ube l+=e.offsetLeft;
fCTdM+t }
(&R/ns~
alert("top="+t+"/nleft="+l);
ei)ljvvmHP }
v'uWmL7C </script>
j:K>3?
eAN]*:]g //VBScript
s^+h> <script language="VBScript"><!--
P F#+G;q; function getIE()
FWI<_KZO dim t,l,a,b
]s-;*o\H set a=document.all.img1
x? 3U3\W t=document.all.img1.offsetTop
W1S7%6y_1 l=document.all.img1.offsetLeft
8P5yaS_ while a.tagName<>"BODY"
[sJ f)< set a = a.offsetParent
P3X;&iT t=t+a.offsetTop
'<_nL8A^ l=l+a.offsetLeft
`%}SK~<R wend
i356m9j msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
;Z|X` <6g end function
7YT%.ID --></script>
yq+'O&+
bb}zn'xC 14. 光标是停在文本框文字的最后
mn;;wp <script language="javascript">
mxk :P function cc()
8A/"ia {
*TQXE:vZ[ var e = event.srcElement;
umZy=KHj var r =e.createTextRange();
0o~? ]C r.moveStart(`character`,e.value.length);
KDr?<"2L r.collapse(true);
9TRS#iVL+* r.select();
%suSZw` }
6L[ Yn?; </script>
u;p.:{' <input type=text name=text1 value="123" onfocus="cc()">
SV#$Cf g 734)s 15. 判断上一页的来源
d_s=5+Yj javascript:
L+,p#w document.referrer
%+gYZv- g&eIfm 16. 最小化、最大化、关闭窗口
i]&C=X <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
!J`>;& <param name="Command" value="Minimize"></object>
&nkYJi(! <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
Hhx"47: <param name="Command" value="Maximize"></object>
3V~871:-~ <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
_b8&$\> <PARAM NAME="Command" value="Close"></OBJECT>
ZXV_Dc =@(&xfTC <input type=button value=最小化 onclick=hh1.Click()>
D^qto{! <input type=button value=最大化 onclick=hh2.Click()>
IcmTF #{D <input type=button value=关闭 onclick=hh3.Click()>
..BIoSrj 本例适用于IE
-7E)u 2F*spu
17.屏蔽功能键Shift,Alt,Ctrl
GaV6h|6_ <script>
Q@]~O- function look(){
_8x:%$ if(event.shiftKey)
u#(VR]u\7 alert("禁止按Shift键!"; //可以换成ALT CTRL
{Q9?Q? }
'J\nvNm document.onkeydown=look;
Fy:CG6@X </script>
]@E_Hx{S mQEE?/xX; 18. 网页不会被缓存
+KV?W+g)` <META HTTP-EQUIV="pragma" CONTENT="no-cache">
NG3!09eY <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
}e$^v*16 <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
XY %er 或者<META HTTP-EQUIV="expires" CONTENT="0">
:[![9JS/ @qj4rt" 19.怎样让表单没有凹凸感?
nE.w <input type=text style="border:1 solid #000000">
4WCWu} 或
1;_tu <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:
ptJ58U$Bb
sa 8JN.B 1 solid #000000"></textarea>
+tO mKY j9Qd
45 20.<div><span>&<layer>的区别?
`pr$l <div>(division)用来定义大段的页面元素,会产生转行
7#/->Y <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
U9w0kcUw#J <layer>是ns的标记,ie不支持,相当于<div>
#r5IwyL (gW#T\Eln 21.让弹出窗口总是在最上面:
wW2b?b{*Z <body onblur="this.focus();">
,U`:IP/L ^h wF= 22.不要滚动条?
9! 'qLO 让竖条没有:
^`M,ju <body style=`overflow:-Scroll;overflow-y:hidden`>
=iJfz </body>
0"l*8%g 让横条没有:
Y9V%eFY5E <body style=`overflow:-Scroll;overflow-x:hidden`>
FuqMT` </body>
`)5,!QPQ7u 两个都去掉?更简单了
a,eR'L<"*- <body scroll="no">
'T=$Q%Qv </body>
VF#2I%R* o[=h=&@5p 23.怎样去掉图片链接点击后,图片周围的虚线?
x=-dv8N? <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
6.#5Ra kyV!ATL1F 24.电子邮件处理提交表单
vh+ '
W <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
%3p~5jhm1 <input type=submit>
}
@r|o:I </form>
nV`n=x DX3xWdnr 25.在打开的子窗口刷新父窗口的代码里如何写?
Xn:5pd;?B6 window.opener.location.reload()
}ACWSk WK (!'=?B " 26.如何设定打开页面的大小
KWuc*! <body onload="top.resizeTo(300,200);">
Eo
h4#fZ\N 打开页面的位置<body onload="top.moveBy(300,200);">
GFA D aTi2=HL=S 27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
,orq*Wd <style>
kT7x
!7C body
<HYK9{Q {background-image:url(logo.gif); background-repeat:no-repeat;
LYTx8 SNLZU%jan background-position:center;background-attachment: fixed}
sd(Yr6~.. </style>
=yT3#A~<G R1,.H92 28. 检查一段字符串是否全由数字组成
k&JB,d-mJ% <script language="javascript"><!--
*\gS 2[S function checkNum(str){return str.match(//D/)==null}
\/qo2'V
j` alert(checkNum("1232142141"
B!PT| alert(checkNum("123214214a1"
sGBm[lplz // --></script>
A=N &(k |4E5x9J 29. 获得一个窗口的大小
WA'4y\ N document.body.clientWidth; document.body.clientHeight
!V%h0OE\ whH_<@! 30. 怎么判断是否是字符
JXT%@w>I if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
Z}X oWT2f else alert("全是字符";
pt/UY<@yoN /Kw}R5l 31.TEXTAREA自适应文字行数的多少
$*k(h|XfwW <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
Kivr)cIG </textarea>