1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
l$.C40v <table border oncontextmenu=return(false)><td>no</table> 可用于Table
.7cQKdvcC ]LNP"vi; 2. <body onselectstart="return false"> 取消选取、防止复制
\W#M]Q X@jml$;$ 3. onpaste="return false" 不准粘贴
"EhA _ =i 6Pd;I,k 4. oncopy="return false;" oncut="return false;" 防止复制
{6v+
Dz> oGXT,38* 5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标
C\
9eR 5f}wQ 6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标
Z>M0[DJ_ P62g7>B5^ 7. <input style="ime-mode:-Disabled"> 关闭输入法
eX$u \$GlB+ iCx 8. 永远都会带着框架
QnVYZUgJeV <script language="javascript"><!--
r!j_KiUy if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
)1&[uE#L // --></script>
* UBU? |Y2u=B 9. 防止被人frame
dN;C-XF3s <SCRIPT LANGUAGE=javascript><!--
62a{Ggs{ if (top.location != self.location)top.location=self.location;
Tig`4d-% // --></SCRIPT>
ZShRE"` If2f7{b 10. 网页将不能被另存为
qp'HRh@P2: <noscript><iframe src=*.html></iframe></noscript>
oM
Q+= s#-`,jqD 11. <input type=button value=查看网页源代码
H8rDG/>^ onclick="window.location = `view-source:`+
http://www.51js.com/`";>
M~p=OM< #.#T+B+9 12.删除时确认
oTT/;~ I <a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删
B]0`b1t U
$e-e/ 除</a>
2["bS++? bp;b;f> 13. 取得控件的绝对位置
!fZ{= //javascript
k G4v> <script language="javascript">
c$bb0J% function getIE(E){
K'Bq@6@C g var t=e.offsetTop;
DMsxHAE1 var l=e.offsetLeft;
ebp18_a| while(e=e.offsetParent){
68W&qzw.[r t+=e.offsetTop;
@=isN'>] O l+=e.offsetLeft;
*Xn{{ }
LoqS45-) alert("top="+t+"/nleft="+l);
M&:[3u- }
+*mi%)I </script>
M')f,5i&$ \Om.pOz //VBScript
5@F1E8T <script language="VBScript"><!--
MXq+aS{ function getIE()
~\6Kq`Y dim t,l,a,b
edx-R-Dc-1 set a=document.all.img1
TW7jp t=document.all.img1.offsetTop
v&(PM{3o l=document.all.img1.offsetLeft
Xg_M{t while a.tagName<>"BODY"
ofC=S$wX set a = a.offsetParent
9l+'V0?` t=t+a.offsetTop
~$Xz~#~ l=l+a.offsetLeft
+.!
F]0ju wend
S bc msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
"6[fqW65 end function
4l <%Q2 --></script>
]O,;t> WA\
P`'lg 14. 光标是停在文本框文字的最后
wi|'pKG <script language="javascript">
[u`v'*0d function cc()
>;-.rJFr {
}4Ef31X8q var e = event.srcElement;
N \1
EWi var r =e.createTextRange();
@A GM=v r.moveStart(`character`,e.value.length);
ds}: t.3}6 r.collapse(true);
\7n ;c r.select();
('hr;s= }
:70[zo7n' </script>
Oe:+%p <input type=text name=text1 value="123" onfocus="cc()">
H$bu*o-Z p6VS<L 15. 判断上一页的来源
Q`j!$r javascript:
ue"?n2 document.referrer
{ss^L (S3\O `5 16. 最小化、最大化、关闭窗口
"#Qqwsw7 <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
=4+Wx8ZeW <param name="Command" value="Minimize"></object>
I?<5
% <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
J$Uj@M <param name="Command" value="Maximize"></object>
&Azfpv <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
5 YjqN <PARAM NAME="Command" value="Close"></OBJECT>
_Vul9= (1Q G]1q <input type=button value=最小化 onclick=hh1.Click()>
9ozN$: <input type=button value=最大化 onclick=hh2.Click()>
}TfZ7~o[ <input type=button value=关闭 onclick=hh3.Click()>
]06orBV 本例适用于IE
fhp\of/@
R 4BF
\-lq~ 17.屏蔽功能键Shift,Alt,Ctrl
PWUS@I <script>
vo<'7, function look(){
.nh }f}j if(event.shiftKey)
c~ x alert("禁止按Shift键!"; //可以换成ALT CTRL
hq+j8w}<- }
`#J0@ - document.onkeydown=look;
{HoeK>rd </script>
~nLE?>x|Z jMFLd 18. 网页不会被缓存
Cb:}AQ = <META HTTP-EQUIV="pragma" CONTENT="no-cache">
drRi<7
i <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
Ix~_.& <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
QAN : 或者<META HTTP-EQUIV="expires" CONTENT="0">
9=RfGx "L ,)4v/J 19.怎样让表单没有凹凸感?
pSMF1Oy <input type=text style="border:1 solid #000000">
f0!i<9< 或
!g|)?XWc <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:
e"g=A=S LKC^Y)6o 1 solid #000000"></textarea>
q%&JAX= Sr Vo0$5) 20.<div><span>&<layer>的区别?
)DG>omCY <div>(division)用来定义大段的页面元素,会产生转行
L?h'^*F H} <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
LeP;HP| <layer>是ns的标记,ie不支持,相当于<div>
Q6qIx=c4 B=!&rKF 21.让弹出窗口总是在最上面:
J]mG!# 9 <body onblur="this.focus();">
2&b?NqEeZ };/;L[,G 22.不要滚动条?
L'A9TW2 让竖条没有:
z:gp\ <body style=`overflow:-Scroll;overflow-y:hidden`>
cpLlkR O </body>
o*5iHa(Qm 让横条没有:
*h([ai"1- <body style=`overflow:-Scroll;overflow-x:hidden`>
)/87<Y;o </body>
~9ZW~z' 两个都去掉?更简单了
PPpq"c <body scroll="no">
rg5ZxN|g </body>
-w'_Q"o2 MJ.K,e 23.怎样去掉图片链接点击后,图片周围的虚线?
xa"8"8 <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
t@"i/@8x$ 8GN_3pT 24.电子邮件处理提交表单
bfV&z+Rv-5 <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
?:woUTyCv <input type=submit>
@y ImR+^.7 </form>
VvFMpPi > a?K![R 25.在打开的子窗口刷新父窗口的代码里如何写?
6,~Y(# window.opener.location.reload()
_-+xzdGvX ,h<xL- 26.如何设定打开页面的大小
\>]C <body onload="top.resizeTo(300,200);">
~vPR9\e 打开页面的位置<body onload="top.moveBy(300,200);">
:MPfCiAv ]Y.GU 7` 27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
|d)*,O4s <style>
N e<D'- body
14DHU {background-image:url(logo.gif); background-repeat:no-repeat;
E:$EK_?:t 2j =i\ B background-position:center;background-attachment: fixed}
'$q=r x </style>
>}7Ml :w,#RcW 28. 检查一段字符串是否全由数字组成
]I^b&N <script language="javascript"><!--
`uh+d function checkNum(str){return str.match(//D/)==null}
&02I-lD4+ alert(checkNum("1232142141"
qP k`e}D alert(checkNum("123214214a1"
?h|&kRq // --></script>
ud
grZ/w] B?gFFU61 29. 获得一个窗口的大小
YZdV0-S document.body.clientWidth; document.body.clientHeight
2 ":W^P H_nIlku 30. 怎么判断是否是字符
DQI
b57j if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
nl)l:A+q8 else alert("全是字符";
PP-U. 2{}8_G 31.TEXTAREA自适应文字行数的多少
p}e1!q;N <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
8\VP)<< </textarea>