1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
Km
$o@ <table border oncontextmenu=return(false)><td>no</table> 可用于Table
>}\s-/ >$TvCw 2. <body onselectstart="return false"> 取消选取、防止复制
9TQVgkW 'tY(&& 3. onpaste="return false" 不准粘贴
+<.o,3 LRts
W(A/ 4. oncopy="return false;" oncut="return false;" 防止复制
!^&VZh #>("(euXMF 5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标
f}"eN/T 3>^]r jFw 6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标
Y!_{:2H8p PPH;'!>s" 7. <input style="ime-mode:-Disabled"> 关闭输入法
/ Ws>;0 Sc/l.]k+ 8. 永远都会带着框架
u*):
D~A <script language="javascript"><!--
W#~7X if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
kl]MP}wc // --></script>
h x&"f e tT>LOI_z 9. 防止被人frame
gT0yI;g] <SCRIPT LANGUAGE=javascript><!--
"3\y~<8%' if (top.location != self.location)top.location=self.location;
51b%uz // --></SCRIPT>
Y|><Ls6Q hPSMPbI 10. 网页将不能被另存为
:CW^$Zvq <noscript><iframe src=*.html></iframe></noscript>
""jW'%wR ^!\AT!OT 11. <input type=button value=查看网页源代码
(;;ji!i onclick="window.location = `view-source:`+
http://www.51js.com/`";>
;b*qunJ3L fs 2MYat 12.删除时确认
tiE|%jOzt <a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删
5{k,/Z[L
'E9{qPLk( 除</a>
h{iuk3G`h6 wpuK?fP 13. 取得控件的绝对位置
6ICW>#fI` //javascript
\OtreYi <script language="javascript">
'mbLK#q function getIE(E){
hdCd:6 var t=e.offsetTop;
JR#4{P@A var l=e.offsetLeft;
j
:B/ FL while(e=e.offsetParent){
#55:qc>m t+=e.offsetTop;
4qp|g'uXT l+=e.offsetLeft;
/uX*FZ }
D$K'Qk alert("top="+t+"/nleft="+l);
/nQuM05*Z }
6" * <0 </script>
OQ hQ!6 #i@f%Bq- //VBScript
TDDMx |{ <script language="VBScript"><!--
EN\cwa#FU function getIE()
lbda/Zx dim t,l,a,b
/]3[| set a=document.all.img1
QR#>Ws t=document.all.img1.offsetTop
K~vJ/9"|R l=document.all.img1.offsetLeft
t_jn-Idcf while a.tagName<>"BODY"
Rtz~:v% set a = a.offsetParent
qsp.`9! t=t+a.offsetTop
FHQ`T\fC$@ l=l+a.offsetLeft
Au'y(KB wend
%rG4X msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
cyJ{AS+ end function
yiQ ?p:DM --></script>
N'VTdf? ?-<lIFFh 14. 光标是停在文本框文字的最后
UgGa]b[9A <script language="javascript">
'wk,t^) function cc()
?'6@m86d {
$ ubU" var e = event.srcElement;
I U" var r =e.createTextRange();
O'wmhLa"W r.moveStart(`character`,e.value.length);
bpwA|H%{M r.collapse(true);
O|,9EOrP r.select();
bh1$
A }
H%@f ^ </script>
XqmB%g( <input type=text name=text1 value="123" onfocus="cc()">
!vAmjjB /S"jO[n9b 15. 判断上一页的来源
?I6rW JcQ6 javascript:
E+O{^C= document.referrer
}w$2,r
gA oYkd%N9P 16. 最小化、最大化、关闭窗口
S4_/%~? <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
Pj
<U|\-? <param name="Command" value="Minimize"></object>
NSz} <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
oL@ -<;zKO <param name="Command" value="Maximize"></object>
T<pG$4_ <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
w-pgtO|Us <PARAM NAME="Command" value="Close"></OBJECT>
ce\d35x! RH;ulAD6(~ <input type=button value=最小化 onclick=hh1.Click()>
4-.K<-T%D <input type=button value=最大化 onclick=hh2.Click()>
b!@PS$BTxq <input type=button value=关闭 onclick=hh3.Click()>
^7spXfSAd 本例适用于IE
HXa[0VOx 7x6M]1F 17.屏蔽功能键Shift,Alt,Ctrl
adP :{j <script>
(0NffM1 function look(){
mp8GHV if(event.shiftKey)
88osWo6rG alert("禁止按Shift键!"; //可以换成ALT CTRL
W]oD(eZ }
z)^|. document.onkeydown=look;
.U0Gm_c0 </script>
fQa*> **j; B[@q.n 18. 网页不会被缓存
9O3 #d <META HTTP-EQUIV="pragma" CONTENT="no-cache">
%LMpErZO <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
+Umsr <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
}(t`s 或者<META HTTP-EQUIV="expires" CONTENT="0">
+<1 |apS1 qS+;u`s 19.怎样让表单没有凹凸感?
Qjfgxy] <input type=text style="border:1 solid #000000">
rQimQ|+ 或
"sN%S's <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:
$CE dJ+0z cb9-~*1 1 solid #000000"></textarea>
?.VKVTX^ 4[$:KGh3 20.<div><span>&<layer>的区别?
_U^[h ! <div>(division)用来定义大段的页面元素,会产生转行
~9+01UU^ <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
d^}p#7mB\ <layer>是ns的标记,ie不支持,相当于<div>
H]/~
#a 031"D*W'i 21.让弹出窗口总是在最上面:
{Ge{@1 <body onblur="this.focus();">
UN.;w3`Oc {1Ra|,; 22.不要滚动条?
(+|+ELfqW 让竖条没有:
5I2,za&e <body style=`overflow:-Scroll;overflow-y:hidden`>
src9EeiV </body>
AabQ)23R2 让横条没有:
=PRQ3/?5 <body style=`overflow:-Scroll;overflow-x:hidden`>
P5<9;PPbZ </body>
A O:F*%Q u 两个都去掉?更简单了
c#N4XsG, <body scroll="no">
lr>NG,N </body>
f(|k0$EIu d&NnpjH}c 23.怎样去掉图片链接点击后,图片周围的虚线?
ynIC (t <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
Q ]CMm2L^f @njNP^'Kx 24.电子邮件处理提交表单
"u^Erj# / <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
Nu"v
.]Y2 <input type=submit>
|eu8;~A </form>
ytIPY7E oVpZR$ 25.在打开的子窗口刷新父窗口的代码里如何写?
MIZdk'.U window.opener.location.reload()
G]ek-[- j?N<40z 26.如何设定打开页面的大小
0V~zZ/e <body onload="top.resizeTo(300,200);">
64?HqO
6( 打开页面的位置<body onload="top.moveBy(300,200);">
h vYRAQR: x
[]ad"R 27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
7
XxZF43 <style>
>N |?>M* body
MI`qzC*% {background-image:url(logo.gif); background-repeat:no-repeat;
U T\4Xk< `"=>lu2H background-position:center;background-attachment: fixed}
rexf#W) </style>
f`hZb 5C!zEI) 28. 检查一段字符串是否全由数字组成
DPT6]pl"y <script language="javascript"><!--
bSsg` function checkNum(str){return str.match(//D/)==null}
So&gDR;b alert(checkNum("1232142141"
8 MO-QO alert(checkNum("123214214a1"
v])ew| // --></script>
_^BA;S@ V$ H(a`! 29. 获得一个窗口的大小
kGV:=h document.body.clientWidth; document.body.clientHeight
B.; qvuM~ QJ XP- 30. 怎么判断是否是字符
ef`_
n+` if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
B%8@yS else alert("全是字符";
ov_l)vt
r84^/+"T 31.TEXTAREA自适应文字行数的多少
vIRT$W' O} <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
qofAA!3z </textarea>