1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
Q04N <table border oncontextmenu=return(false)><td>no</table> 可用于Table
`@Qq<T}V K@?S0KMK 2. <body onselectstart="return false"> 取消选取、防止复制
Z/2#h<zj Wk$%0xZ7 3. onpaste="return false" 不准粘贴
jI y'mGaG Q4Cw{2r 4. oncopy="return false;" oncut="return false;" 防止复制
`VS/Xyp 30B!hj$C 5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标
XLOk + Fn ,{]>U'- 6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标
ThFI=K %7hYl'83 7. <input style="ime-mode:-Disabled"> 关闭输入法
aA\v
|~uCLf> 8. 永远都会带着框架
L-$GQGk{ <script language="javascript"><!--
n!f@JHL if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
.Z9Bbab: // --></script>
%40|7O <.:B .k 9. 防止被人frame
^#_@Kq%th <SCRIPT LANGUAGE=javascript><!--
zR]l2zL3 if (top.location != self.location)top.location=self.location;
38JvJR yK} // --></SCRIPT>
FVHEb\Z HPu nNsA 10. 网页将不能被另存为
k2O==IG]6 <noscript><iframe src=*.html></iframe></noscript>
h( Iti& _%.atW7 11. <input type=button value=查看网页源代码
gl HHr onclick="window.location = `view-source:`+
http://www.51js.com/`";>
HQ4o^ WC Wny{qj)= 12.删除时确认
?HU(0Vgn' <a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删
?n[+0a:8E UXe @c@3 除</a>
%/~Sq?f-9@ &Tl3\T0D 13. 取得控件的绝对位置
Xi$uK-AHpj //javascript
z+Y0Zh";/# <script language="javascript">
+AXui|mn function getIE(E){
.p <!2 var t=e.offsetTop;
d)9=hp;,V var l=e.offsetLeft;
o2&mhT while(e=e.offsetParent){
,@(lYeD" t+=e.offsetTop;
z!?xz l+=e.offsetLeft;
$1/yc#w
u }
|"\A5v|1 alert("top="+t+"/nleft="+l);
4fp}`U }
@7.Ews5Mke </script>
y1@{(CDp" vr2t MD //VBScript
W!htCwnkF <script language="VBScript"><!--
.y|* function getIE()
A)'{G dim t,l,a,b
PC=b.H8P+W set a=document.all.img1
b$%W<D t=document.all.img1.offsetTop
U H
`= l=document.all.img1.offsetLeft
}zj_Pp while a.tagName<>"BODY"
?3"lI,!0 set a = a.offsetParent
rVkRU5 t=t+a.offsetTop
sF f@> l=l+a.offsetLeft
lg~Gkd6 wend
-PoW56 msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
_-^a8F>/19 end function
qgDd^0 --></script>
j%Usui<DL +<&_1%5+ 14. 光标是停在文本框文字的最后
g \&Z_ <script language="javascript">
`l'z#\ function cc()
<Zn]L: {
b-\ 1D;] var e = event.srcElement;
2w+w'Ag_R var r =e.createTextRange();
G[ @RZ~o4 r.moveStart(`character`,e.value.length);
yIA-+# r[ r.collapse(true);
6|| zfH r.select();
/*i[MB }
?s6v>#H% </script>
?sk{(UN] <input type=text name=text1 value="123" onfocus="cc()">
Y2W|b5 }k~ih?E^s 15. 判断上一页的来源
;M1# M: javascript:
+9<"Y6 document.referrer
$mgW|TBXCQ W 2&o'(P\ 16. 最小化、最大化、关闭窗口
pE,2pT2> <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
kc-=5l <param name="Command" value="Minimize"></object>
,K
8R%B <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
h'jc4mu0 <param name="Command" value="Maximize"></object>
"m4._4U <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
QV)>+6\ <PARAM NAME="Command" value="Close"></OBJECT>
";yey ] L7;8:^ v <input type=button value=最小化 onclick=hh1.Click()>
jmPnUn <input type=button value=最大化 onclick=hh2.Click()>
|Bz1u|uc <input type=button value=关闭 onclick=hh3.Click()>
[;t-XC?[nk 本例适用于IE
J2adG+= \|&KD 17.屏蔽功能键Shift,Alt,Ctrl
N?`V;`[ <script>
. |%n"{ function look(){
r2yJ{j&s if(event.shiftKey)
ti'B}bH>' alert("禁止按Shift键!"; //可以换成ALT CTRL
Bs)'Gk`1 }
0Un?[O document.onkeydown=look;
0$JH5RC </script>
^F,sV* 2. '` mGu 18. 网页不会被缓存
0xVw{k}1U <META HTTP-EQUIV="pragma" CONTENT="no-cache">
=HMa<"-8 <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
2,aH1Xbex <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
~-R%m 或者<META HTTP-EQUIV="expires" CONTENT="0">
G?kK:eV qYoB;gp 19.怎样让表单没有凹凸感?
@,Z0u2WLl6 <input type=text style="border:1 solid #000000">
5EU~T.4C< 或
!7Eodq-0 <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:
ZtyDip'x CRBj> 1 solid #000000"></textarea>
{ETM > zD)/Q FILy 20.<div><span>&<layer>的区别?
}@eIO| <div>(division)用来定义大段的页面元素,会产生转行
/~MH]Gh <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
N=AHS <layer>是ns的标记,ie不支持,相当于<div>
Kv<f<>|L ^M{,{bG 21.让弹出窗口总是在最上面:
JIhEkY <body onblur="this.focus();">
y];-D>jk
C];P yQS 22.不要滚动条?
wBcoh~
(y 让竖条没有:
q3AqU?f <body style=`overflow:-Scroll;overflow-y:hidden`>
s1q8r!2\w </body>
c/Xg ARCO 让横条没有:
rtS' 90` <body style=`overflow:-Scroll;overflow-x:hidden`>
l+[:Cni </body>
R&9FdM3K`: 两个都去掉?更简单了
lD[37U! <body scroll="no">
Fvf|m7 </body>
S=(<m%f Y=p!xr> 23.怎样去掉图片链接点击后,图片周围的虚线?
h);^4cU <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
M?!@L:b[ ^|H={pd'c0 24.电子邮件处理提交表单
#l ZK_N|1x <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
N+'j on}U <input type=submit>
_Ao$)Gu) </form>
"$XX4w
M sxsb)a 25.在打开的子窗口刷新父窗口的代码里如何写?
zw['hqW window.opener.location.reload()
f. "\~ xNzGp5H 26.如何设定打开页面的大小
i|J%jA <body onload="top.resizeTo(300,200);">
GL=}Vu`(* 打开页面的位置<body onload="top.moveBy(300,200);">
<q8@a0e@ q pCI[[ 27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
_]-4d_&3( <style>
C,An\lsT body
nq)F$@ {background-image:url(logo.gif); background-repeat:no-repeat;
z@yTkH_ [ n7>g background-position:center;background-attachment: fixed}
7p{Pmq[ </style>
7
!$[XD s{-gsSmE 28. 检查一段字符串是否全由数字组成
MF8-q'upyT <script language="javascript"><!--
=j62tDS function checkNum(str){return str.match(//D/)==null}
_p^"l2%D/ alert(checkNum("1232142141"
{uj_4Ft alert(checkNum("123214214a1"
vd{QFJ // --></script>
9<6q(]U ovdJ[bO 29. 获得一个窗口的大小
hbJ>GSoZ, document.body.clientWidth; document.body.clientHeight
z5kAf~A $iu[-my_ 30. 怎么判断是否是字符
nN\H'{Wzd if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
{%f{U"m else alert("全是字符";
X` zWw_i <7M-?g:vj 31.TEXTAREA自适应文字行数的多少
y3zP`^
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
Ix5&B6L8 </textarea>