1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
L*(!P4S%} <table border oncontextmenu=return(false)><td>no</table> 可用于Table
%2I >0 v1R t$[ 2. <body onselectstart="return false"> 取消选取、防止复制
VYo2m *3!#W|#=]N 3. onpaste="return false" 不准粘贴
6f'THU$ LBIsj}e 4. oncopy="return false;" oncut="return false;" 防止复制
^~7/hm: j^T
i6F>f 5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标
r%uka5@ #5%\~f 6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标
FJ+n-
\ G m~2s;/ 7. <input style="ime-mode:-Disabled"> 关闭输入法
DtFzT>$^F } %bP9 8. 永远都会带着框架
_SQQS67fu" <script language="javascript"><!--
6k=*O|r if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
UhX)?'J // --></script>
z+5%.^Re GbwqrH+ 9. 防止被人frame
PAy/"R9DT- <SCRIPT LANGUAGE=javascript><!--
nB9(y4 if (top.location != self.location)top.location=self.location;
WJ&a9]&C // --></SCRIPT>
gucgNpX KsDovy< 10. 网页将不能被另存为
y5/LH~&Ov <noscript><iframe src=*.html></iframe></noscript>
/cX%XZg NY3/mS3w 11. <input type=button value=查看网页源代码
bH Nf> onclick="window.location = `view-source:`+
http://www.51js.com/`";>
5OM*NT t =K;M\_k%y 12.删除时确认
(7 O?NS <a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删
8-s7s!j EEp~\^- 除</a>
OnND(YiX A|`mIma# 13. 取得控件的绝对位置
Koi-b //javascript
2uzy]faM <script language="javascript">
ec&K}+p@ function getIE(E){
K9tr Iy$v var t=e.offsetTop;
oIv\Xdc8 1 var l=e.offsetLeft;
"KKw\i while(e=e.offsetParent){
)1E#'v12" t+=e.offsetTop;
L#`Vr$ l+=e.offsetLeft;
r:U/a=V }
DR(/|?k+ alert("top="+t+"/nleft="+l);
_W }
@ruWnwb </script>
>zV sEHA?UP$<F //VBScript
VJSkQ\KD <script language="VBScript"><!--
.c]@xoC function getIE()
=Bos>;dl dim t,l,a,b
vEc<|t set a=document.all.img1
;$g?W" t=document.all.img1.offsetTop
)ml#2XP!f l=document.all.img1.offsetLeft
NJmyp!8 while a.tagName<>"BODY"
X@\ 9}*9 set a = a.offsetParent
[{.9#cQ" t=t+a.offsetTop
jk{m8YP)E l=l+a.offsetLeft
8<=]4- X@ wend
u,JUMH]@ msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
"J{A}g[ end function
Sr>5V --></script>
JOo+RA5d ke2}@|?t 14. 光标是停在文本框文字的最后
w3FEX$`_ <script language="javascript">
q"u,r6ED function cc()
I.- I4F)D {
'DD~xCXE var e = event.srcElement;
C1x(4&h var r =e.createTextRange();
(s,u9vj=>L r.moveStart(`character`,e.value.length);
^!Tq(t5V r.collapse(true);
@7J;}9E r.select();
->'xjD }
lmYyaui </script>
:8U@KABH@h <input type=text name=text1 value="123" onfocus="cc()">
$pajE^d4V B:6VD /qC 15. 判断上一页的来源
3Qd%`k javascript:
M%2w[<-8c document.referrer
~H:.&'E f@ .s(i=z 16. 最小化、最大化、关闭窗口
I\f\k>; <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
.RPh#FI6J <param name="Command" value="Minimize"></object>
22Oe~W; <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
>NZJ-:t <param name="Command" value="Maximize"></object>
il7gk< <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
{-51rAyi <PARAM NAME="Command" value="Close"></OBJECT>
$AHdjQ[;6- }CvhLjo <input type=button value=最小化 onclick=hh1.Click()>
pg3h>)$/ <input type=button value=最大化 onclick=hh2.Click()>
QG
1vP.K <input type=button value=关闭 onclick=hh3.Click()>
g2 tM!IRQ 本例适用于IE
;FnS=Z OE2r2ad 17.屏蔽功能键Shift,Alt,Ctrl
pE6r7 <script>
@;Xa&* function look(){
cG!dMab( if(event.shiftKey)
c3N,P<# alert("禁止按Shift键!"; //可以换成ALT CTRL
~8Ez K_c }
o)M<^b3KO document.onkeydown=look;
Wb;D9Z </script>
=QhK|C!$A vAzSpiv- 18. 网页不会被缓存
#0c;2}D <META HTTP-EQUIV="pragma" CONTENT="no-cache">
sV`p3L8pl <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
is`~C <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
\vgM`32< 或者<META HTTP-EQUIV="expires" CONTENT="0">
[E0.4FLT! R0T{9,;[` 19.怎样让表单没有凹凸感?
fz<GPw
<input type=text style="border:1 solid #000000">
@"n]v)[4 或
Svm'ds7> <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:
$ZRvvm!f lbC9^~T+ 1 solid #000000"></textarea>
G=&nwSL j`%a2 20.<div><span>&<layer>的区别?
a7"Aq:IjU <div>(division)用来定义大段的页面元素,会产生转行
N^zFKDJG <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
z)%]#QO <layer>是ns的标记,ie不支持,相当于<div>
"ed
A t>eeOWk3 21.让弹出窗口总是在最上面:
Zo@ <body onblur="this.focus();">
98lz2d/Fcq n7L|XkaQ 22.不要滚动条?
->2m/d4a 让竖条没有:
KdC'#$ <body style=`overflow:-Scroll;overflow-y:hidden`>
3+H[S#e:Z </body>
=$uSa7t# 让横条没有:
w-LaSJ(T <body style=`overflow:-Scroll;overflow-x:hidden`>
lbMok/a2o </body>
zG\:#,9 两个都去掉?更简单了
#1Iev7w <body scroll="no">
9z7rv, </body>
uVa`2]NV r t<MO~_`! 23.怎样去掉图片链接点击后,图片周围的虚线?
v>sjS3 <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
a$$aM2.2 !G;|~|fMV 24.电子邮件处理提交表单
VCa`|S?2 <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
kn}bb*eZ <input type=submit>
2j=HxE </form>
!%/(a)B$^$ 6\xfoy|j 25.在打开的子窗口刷新父窗口的代码里如何写?
BB.120v&N window.opener.location.reload()
,y gDNF $~NB
.SY 26.如何设定打开页面的大小
GB}!7W" <body onload="top.resizeTo(300,200);">
/hAy1V6 打开页面的位置<body onload="top.moveBy(300,200);">
+7r?vo1 4VHX4A}CgA 27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
CQH^VTQ <style>
H6<3'P body
u^( s0q {background-image:url(logo.gif); background-repeat:no-repeat;
WP
!u3\91 Bs^p!4=
background-position:center;background-attachment: fixed}
ICzcV };$ </style>
UVgDm&FF S0?e/VWy 28. 检查一段字符串是否全由数字组成
\ \g Aa-}: <script language="javascript"><!--
-d^c!Iu| function checkNum(str){return str.match(//D/)==null}
p$a+?5'Q alert(checkNum("1232142141"
>f(M5v(D\ alert(checkNum("123214214a1"
q>[}JtXK // --></script>
(Ji=fh+ `_(N(dm 29. 获得一个窗口的大小
3V3 q
vd document.body.clientWidth; document.body.clientHeight
Dp^6|T* HU "s7}eWM*a 30. 怎么判断是否是字符
wexa\o if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
'}E"Mdb else alert("全是字符";
s"x(i AA[?a
31.TEXTAREA自适应文字行数的多少
K[i&!Z&
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
iJr(;Bq </textarea>