TA的每日心情 | 衰 2019-8-18 09:37 |
|---|
签到天数: 2 天 [LV.1]初来乍到
|
1.oncontextmenu="window.event.returnvalue=false"将彻底屏蔽鼠标右键" w6 E' e6 X- D: E3 k
<tableborderoncontextmenu=return(false)><td>no</table>可用于Table : l+ Q7 c2 Q' V8 y
2.<bodyonselectstart="returnfalse">取消选取、防止复制
' H8 p( u3 b$ q1 h" E& ?0 }/ J3 N/ r5 I5 |! t& r. }: q8 u: W
3.onpaste="returnfalse"不准粘贴
/ J' [8 U$ u5 k' n: T R7 s
^2 G8 \0 ]" T8 n. V2 G) W4.oncopy="returnfalse;"oncut="returnfalse;"防止复制9 N4 h5 h* R0 o K
7 P0 [: D" d) _9 u2 t5.<linkrel="ShortcutIcon"href="favicon.ico">IE地址栏前换成自己的图标
( s# U/ w) R8 s' j" p5 H+ |. \/ y6 n- A8 ]" Z
6.<linkrel="Bookmark"href="favicon.ico">可以在收藏夹中显示出你的图标0 t, @ X- v+ F; ^, i
: J6 w7 I, D8 p) v" l
7.<inputstyle="ime-mode:disabled">关闭输入法
# x1 Q7 {! x# e: n5 S( J6 ^( B+ @8 ?: } [6 l% P1 M
8.永远都会带着框架# z) ^5 e( U2 t
<scriptlanguage="javascript"><!--1 n- z: f; N1 w* g& m# i" r& _
if(window==top)top.location.href="frames.htm";//frames.htm为框架网页
9 W, `# T! Z! r4 M9 g- x) V, r4 Q8 ^* j//--></script>" K1 ?! U) @9 p& V
( o$ W+ N- ?0 [9.防止被人frame. ]( B$ W+ y4 p
<SCRIPTLANGUAGE=javascript><!--3 [* M$ ~5 m s& K- y3 a9 {
if(top.location!=self.location)top.location=self.location;! D5 J/ @% U5 k9 ^) t" B2 X
//--></SCRIPT>, R9 \4 b3 ^8 I( |
* }5 j1 {; H+ S# n10.<noscript><iframesrc=*.html></iframe></noscript>网页将不能被另存为
# n" ]. z; ^8 f' X; G! ?# k0 C% K" F5 M: V" k: E
11.<inputtype=buttonvalue=查看网页源代码
. {& `6 r3 u1 M7 G0 ~+ donclick="window.location='view-source:'+'<IMG src="pic/url.gif" align=absMiddle border=0>' target=_blank>http://www.csdn.net/">
7 A [, L2 v. g" w8 ]1 w
. K* ^9 m8 a! I3 _' K12.怎样通过asp的手段来检查来访者是否用了代理% d( Z* l, Z( `
<%ifRequest.ServerVariables("HTTP_X_FORWARDED_FOR")<>""then( J7 f7 l* s2 c5 D
response.write"<fontcolor=#FF0000>您通过了代理服务器,"&_; p- j; _5 @2 F) y
"真实的IP为"&Request.ServerVariables("HTTP_X_FORWARDED_FOR") V0 D5 K1 Q! n2 `+ L* j
endif
+ I: ?1 o& o5 w%>5 @3 ?* k0 w6 T
1 i$ ^2 O- g5 V+ h
13.取得控件的绝对位置
5 P# E9 r5 ?0 s! {+ ^( C2 l& A
c: [# o( ^6 Y! H- I//javascript
2 h+ w) j5 x- M4 V<scriptlanguage="javascript">
( R* ^9 N, P" \% tfunctiongetIE(e){8 P2 r* p9 \) U& c8 B/ ]( R
vart=e.offsetTop;- v5 a4 B4 p& y5 v6 t1 L' ^
varl=e.offsetLeft;
! I6 v9 p6 {+ w* j/ kwhile(e=e.offsetParent){1 p i, [7 ^7 t& f7 ~9 Y# R. P
t+=e.offsetTop;* g: \: s: a5 n2 Q" W7 O% F+ W1 ^
l+=e.offsetLeft;
, R# N. R) P; g6 ~4 ?}
q, V, c2 Z# [. V! `alert("top="+t+"\nleft="+l);
( M, Z7 l+ q4 O: ]0 Z2 e}
4 W; f. H1 t$ Y- J0 q* A! h</script>
1 D" o0 B2 d! t7 u- l' K! g3 ^$ C
//VBScript
. }9 r% `' E7 a- m; U5 J' a) D% u; S<scriptlanguage="VBScript"><!--
9 m6 _2 r# U6 ~6 l7 T" J' {: GfunctiongetIE()/ S v4 O8 H' z; `
dimt,l,a,b
% Q( ~4 z2 I* ~seta=document.all.img1( u7 w2 k: j6 P2 v0 A
t=document.all.img1.offsetTop
! w" T, K4 ^) h" i* r3 {8 Y4 Yl=document.all.img1.offsetLeft5 B( {0 d* ]/ ?# I
whilea.tagName<>"BODY"
$ e( l) `$ s- b$ t1 S% {seta=a.offsetParent
+ a+ T; ]: V% |. dt=t+a.offsetTop
( W% g' V7 T; ]' ^ C" i ~0 bl=l+a.offsetLeft
3 a5 L0 T4 |4 V# Y: D% {wend
1 S; v5 `0 j" Wmsgbox"top="&t&chr(13)&"left="&l,64,"得到控件的位置"
, A2 N* L! j! w- `) Dendfunction1 P4 ]8 z- W+ x3 o5 p/ ^2 Y
--></script>2 g, t6 H. N4 b( s
" Y" Q" ?9 i9 D4 \+ |) o$ D14.光标是停在文本框文字的最后( y, ?1 Y9 Q% B& P
<scriptlanguage="javascript">9 Q7 r* M, |: c
functioncc()
8 D+ }. C# @, u: _) i) O i. A/ |9 x{
" a% X! O; A2 ?' \; uvare=event.srcElement;5 q2 a7 t2 ^ K% V% R
varr=e.createTextRange();
5 d7 h. {1 N! ^r.moveStart('character',e.value.length);
, o! P* Y( O O, m. \r.collapse(true);
8 }) o! |6 X1 ^: Z7 a8 {( p4 j2 i5 {r.select();( r8 a$ q+ d. g8 f
}8 M" Z! {1 ^ X2 G
</script>
3 w+ ?( P8 l3 n' i: n. W, h<inputtype=textname=text1value="123"onfocus="cc()">% @# R1 L: S; {9 s5 `: P
% g1 z2 Y6 e2 Q$ b4 r
15.判断上一页的来源
2 u+ ~4 ^& T ?6 [6 _. i: s, q* W7 Dasp:. M( V0 w- d6 r+ N: \/ j; `: j
request.servervariables("HTTP_REFERER")
! O/ Y9 p1 |2 c0 {' a# Q; c* W. c t' `( C
javascript:2 `; ]$ ^* F. z3 i+ C" I2 n1 B2 X# Z: m
document.referrer
- e2 [+ U1 S! H9 l
, o. x/ c" M5 _8 }16.最小化、最大化、关闭窗口
3 p0 Z/ d% k; G" [<objectid=hh1classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
$ W I! Z" l/ I3 ^<paramname="Command"value="Minimize"></object>+ c- v' v) _( [# V. M8 I
<objectid=hh2classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">6 m( s! T8 p0 A- L0 t. x, Q0 @
<paramname="Command"value="Maximize"></object># T; I- R/ h4 I# g
<OBJECTid=hh3classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">3 x+ H" g: B/ Y! h+ g: B
<PARAMNAME="Command"value="Close"></OBJECT>( H0 H. ^( u, S4 S, P) h
$ M- v4 }% |2 q0 z+ `<inputtype=buttonvalue=最小化onclick=hh1.Click()>3 v5 e1 f7 {, G8 G% d5 h2 }) x/ ?- t- s
<inputtype=buttonvalue=最大化onclick=hh2.Click()>
3 F- h. M j# J" x; s: o7 c. j<inputtype=buttonvalue=关闭onclick=hh3.Click()>
" c9 j7 n4 U. E* Z+ ?本例适用于IE
9 m; I9 `, i) M. w L! k5 x( o
& @6 m4 l# E, N g! ~1 g) r17.; d9 h! w. j4 w% U0 }6 T5 D
<%- D; e. @6 F, N1 l
'定义数据库连接的一些常量8 Z% t: Z8 r% \+ U8 W1 o3 M! F. e9 [
ConstadOpenForwardOnly=0'游标只向前浏览记录,不支持分页、Recordset、BookMark9 f& w6 u! X" D! D* T. a/ Z
ConstadOpenKeyset=1'键集游标,其他用户对记录说做的修改将反映到记录集中,但其他用户增加或删除记录不会反映到记录集中。支持分页、Recordset、BookMark
3 w: C9 R$ V! `0 t# @; I- VConstadOpenDynamic=2'动态游标功能最强,但耗资源也最多。用户对记录说做的修改,增加或删除记录都将反映到记录集中。支持全功能浏览(ACCESS不支持)。
4 @* [- ~7 O ]1 X+ O4 CConstadOpenStatic=3'静态游标,只是数据的一个快照,用户对记录说做的修改,增加或删除记录都不会反映到记录集中。支持向前或向后移动
; U; ^( N6 e; N* G% V/ b4 A( I, t
0 F. {) l( x2 `ConstadLockReadOnly=1'锁定类型,默认的,只读,不能作任何修改
( a% n0 X& x/ S7 hConstadLockPessimistic=2'当编辑时立即锁定记录,最安全的方式! n; |1 {( M7 i( q2 a, i
ConstadLockOptimistic=3'只有在调用Update方法时才锁定记录集,而在此前的其他操作仍可对当前记录进行更改、插入和删除等4 P" M) |8 ^" W
ConstadLockBatchOptimistic=4'当编辑时记录不会被锁定,而更改、插入和删除是在批处理方式下完成的2 B5 X1 p. L& T# `; c& ?: u) P
Z) ?4 \' F+ E9 F. { t7 q
ConstadCmdText=&H0001
+ H' M$ i2 W) L/ sConstadCmdTable=&H00024 F9 D( h. n' y9 { S$ m
%>
1 k0 `% V: X4 A/ U5 r3 C! c* ]; ?8 ], ^
18.网页不会被缓存
T) U1 F" D3 RHTM网页
! _( D4 \4 ~& `+ ?<METAHTTP-EQUIV="pragma"CONTENT="no-cache">6 D$ ]- @& W6 P0 @
<METAHTTP-EQUIV="Cache-Control"CONTENT="no-cache,must-revalidate">
# B) a @* C6 S% h K<METAHTTP-EQUIV="expires"CONTENT="Wed,26Feb199708:21:57GMT">9 s# G( K8 X! B& E& V$ S5 K/ {
或者<METAHTTP-EQUIV="expires"CONTENT="0">1 n2 ~0 S d) V3 U3 G' P6 i8 D
ASP网页
% P" |- L* ~$ x0 s- ]Response.Expires=-17 q9 {1 [- x5 `5 k6 ~
Response.ExpiresAbsolute=Now()-1
+ b% c% D, t% H( mResponse.cachecontrol="no-cache"
$ E- t4 o9 c" H9 f* _" lPHP网页2 p+ [5 C `7 Z( z* ?1 H4 T
header("Expires:Mon,26Jul199705:00:00GMT");
$ t/ K+ j. O8 K( kheader("Cache-Control:no-cache,must-revalidate");
/ I$ ^/ N& J; a( d2 r" wheader("Pragma:no-cache");
9 K4 c2 Q6 F: E9 b% A% q% B# d7 X3 K# s1 S! L2 `5 h1 K
' b" m7 c, V: D/ t
19.检查一段字符串是否全由数字组成
$ A8 i8 H9 W5 l; Z. x<scriptlanguage="javascript"><!--5 {# R2 ^4 h7 o4 B
functioncheckNum(str){returnstr.match(/\D/)==null}
1 M8 V* ^# [( ~+ \$ Xalert(checkNum("1232142141"))
; |. e' x D- I2 t: Q: D6 l4 Walert(checkNum("123214214a1"))
. ?" \9 v# J1 j( z3 I2 @//--></script>
! M& H9 w( b3 v& g- w" a# G) _20.获得一个窗口的大小
0 _4 Y2 q" ~: T; r( s9 Idocument.body.clientWidth,document.body.clientHeight
0 i8 l0 Q+ I9 F% C% v7 E0 ~' D" |. L2 X: L. D# R! H
21.怎么判断是否是字符. |, ]0 w9 Z+ V: b6 e, I, N
if(/[^\x00-\xff]/g.test(s))alert("含有汉字");
9 L7 I8 y) u* c+ Q) I7 v3 Lelsealert("全是字符");
* \4 K: `7 j( f1 \7 i1 l& _+ C% ~# K1 I
22.TEXTAREA自适应文字行数的多少$ e3 H2 Z; o& Q7 T" g' X
<textarearows=1 name=s1 cols=27> J1 A$ r( e. x4 F, E& ^
</textarea>* U" f. t" L. h5 e- e/ f$ C
1 S7 f2 N' P; \) v) @) Y. a1 \
23.日期减去天数等于第二个日期
% e' h( S# i/ M" G1 r* l<scriptlanguage=javascript>$ T4 G( i1 l+ o K/ I& t6 d" S8 q% R" q
functioncc(dd,dadd)
" i+ O7 f) k/ o- r( M2 z. [$ T{/ n! k1 b2 u" l* l x8 B1 [2 C
//可以加上错误处理
9 s" c; D0 F, D& s1 s6 bvara=newDate(dd)! x6 n" C; ^- B3 b* ]* D' z
a=a.valueOf()4 p1 S; _9 X, M0 B5 v' B9 ?
a=a-dadd*24*60*60*1000
' G; b& g" v7 x, l [a=newDate(a)
5 Z7 J( D( T( |# Valert(a.getFullYear()+"年"+(a.getMonth()+1)+"月"+a.getDate()+"日")
4 ]9 x9 i6 u5 X1 [6 O% W8 k# B}
& c1 B9 F$ J" a7 vcc("12/23/2002",2)2 k3 k* {' {1 C
</script>) r$ K1 a0 K2 V5 D" `
6 J. a# ]: B) Z9 ~6 m+ O6 {( s' T
24.选择了哪一个Radio7 @! Z- t+ Y! i' `& |% u5 M$ U
<HTML><scriptlanguage="vbscript">
6 a- _" u) w5 g' Qfunctioncheckme()
) @+ \2 n0 C- {; S( z# fforeachobinradio1
2 `; j' Y% v+ k% iifob.checkedthenwindow.alertob.value
}6 W: ?7 C5 B u8 a& j: x) Hnext
8 L2 Q7 _9 a+ o! H4 ?endfunction8 |: K3 o* _' L" l) W
</script><BODY>
$ f& o1 o1 z' H<INPUT name="radio1" type="radio" value="style" checked>style
, n. k; a$ _+ Z# }7 Y<INPUT name="radio1" type="radio" value="barcode">Barcode; i; u' I+ C3 @* s# j+ d: F r
<INPUT type="button" value="check"onclick="checkme()">4 V% I2 q4 {' T3 ^
</BODY></HTML>
* V4 ^, X- N( Z5 T# m' P4 J
% v4 t5 J8 J" n5 B) d( Y v) e9 U25.获得本页url的request.servervariables("")集合. ^" V8 ?1 R" C" T2 H& B' w/ R _% x
Response.Write"<TABLEborder=1><!--TableHeader--><TR><TD><B>Variables</B></TD><TD><B>value</B></TD></TR>"
2 B* H7 S+ y$ z' LforeachobinRequest.ServerVariables
8 D% ~' s) v0 \. m. V9 ]$ gResponse.Write"<TR><TD>"&ob&"</TD><TD>"&Request.ServerVariables(ob)&"</TD></TR>"
) k) H% Y& u F% hnext
' _' ~8 i9 O# E. SResponse.Write"</TABLE>"
" f( B3 g( i$ g* {
+ ^% ?) ?& |* M26.+ k# v7 m9 G& g& x* H0 U: G
本机ip<%=request.servervariables("remote_addr")%>4 G2 m6 a4 D& L! {% ~
服务器名<%=Request.ServerVariables("SERVER_NAME")%>
6 D' f+ ^( u' \: q服务器IP<%=Request.ServerVariables("LOCAL_ADDR")%>" M+ R. h( V$ a r. o6 `% h
服务器端口<%=Request.ServerVariables("SERVER_PORT")%>- ]& j6 d9 U1 l5 W
服务器时间<%=now%>' M; d. h2 f3 J) u5 T( P
IIS版本<%=Request.ServerVariables"SERVER_SOFTWARE")%>, y* L- l# M" J4 V- @, \
脚本超时时间<%=Server.ScriptTimeout%>
z1 _7 B) _9 E$ A9 ^" S本文件路径<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
: i1 h2 o% Q; o# Q: j; ~ r. h% ~服务器CPU数量<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>
$ H1 c! u, [7 G; Q; r1 i服务器解译引擎<%=ScriptEngine&"/" & ScriptEngineMajorVersion &"." & ScriptEngineMinorVersion & "." & ScriptEngineBuildVersion%>
1 {: L% m" Z6 x' f, k( T8 S5 E服务器操作系统<%=Request.ServerVariables("OS")%>( M/ S- M, o* y1 @) [# ~. a: c
2 G9 G- N; R# {3 d# i b27.ENTER键可以让光标移到下一个输入框
- t8 ]0 o4 l; G" Q* ]6 l7 z<input>2 C0 T* H9 v8 D$ ]
8 F' x2 Z3 ^- {/ c28.检测某个网站的链接速度:
* v- Q0 h/ u8 f1 Z( N! G9 @把如下代码加入<body>区域中:1 s/ V$ A. s# [. C8 T3 B- Y+ E
<scriptlanguage=javascript>8 K u7 ~6 j7 \* s& c1 ?8 f9 m
tim=1+ Q' ~/ h8 q, A! ~
setInterval("tim++",100)
. [; J; K! b& \: t2 Qb=1
& x4 \: ^% D# a* v' U
% a+ O$ t1 I$ Vvarautourl=newArray()
% N- `" B" L! Q7 Z& q% X5 |autourl[1]="< src="pic/url.gif" align=absMiddle border=0>www.njcatv.net"
2 @+ B. N5 Y3 p% Eautourl[2]="javacool.3322.net"$ f+ m K- N0 Z. e9 I5 C: a( F1 ~$ j
autourl[3]="< src="pic/url.gif" align=absMiddle border=0>www.sina.com.cn", u+ r( \" s+ j6 p* K
autourl[4]="www.nuaa.edu.cn"
0 P& |: o3 A; M) V$ Q4 @6 }autourl[5]="< src="pic/url.gif" align=absMiddle border=0>www.cctv.com"
& N, ~) v V4 \3 ]" U9 t% W! I/ t6 B+ Q4 ^! E' Y
functionbutt(){
% E4 ~; P; u7 S" `! Cdocument.write("<formname=autof>")5 M, h' M& l: \- @! b* c
for(vari=1;i<autourl.length;i++)2 C* b; k: Y) l& W# Z
document.write("<inputtype=textname=txt"+i+"size=10value=测试中……>=》<inputtype=textname=url"+i+"size=40>=》<inputtype=buttonvalue=GOonclick=window.open(this.form.url"+i+".value)><br/>")4 y+ D- q9 F) ]* v
document.write("<inputtype=submitvalue=刷新></form>")
2 q4 C0 a9 p7 t: D8 O}
" C" @0 W0 L4 d- L' Xbutt(); z3 B9 P' A, g8 O: I7 u4 {6 t2 u, T
functionauto(url){) S& n4 O, @' r# U
document.forms[0]["url"+b].value=url
3 s9 p8 ~1 d0 z3 kif(tim>200)% d/ w) A- W" m1 F P' P( Z% A
{document.forms[0]["txt"+b].value="链接超时"}/ B( C3 H, \% X4 J. M
else
# V* p( B% c) _4 }1 O% `4 m8 e{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}$ A6 k5 B1 n$ m% E [5 E
b++
( Q j5 X3 A r& y( K: Q0 v, O6 X}( g+ r0 P4 K3 N' h# u
functionrun(){for(vari=1;i<autourl.length;i++)document.write("<imgsrc=http://"+autourl+"/"+Math.random()+"width=1height=1onerror=auto('< src="pic/url.gif" align=absMiddle border=0>http://";+autourl+"')>")}6 N" W+ p4 C4 u- x% a
run()</script>
9 L5 h7 h. ~( i9 Y% n O4 l+ i0 l- N. l6 ^
9 ~+ W2 |( D* N29.各种样式的光标# U2 X* N, d) c6 w
auto:标准光标
# O/ W+ V. b7 Q& F% K7 X) Fdefault:标准箭头
. t, B+ N4 B9 h1 s! s# Vhand:手形光标, F; m+ |7 @4 e4 Q0 G# Z8 r o
wait:等待光标
4 ]! T" Z2 s8 z. Z/ ytext:I形光标8 X9 X0 \" F: J! I+ ?
vertical-text:水平I形光标
" X/ Q* o0 O0 V5 e5 `; N: V6 Wno-drop:不可拖动光标4 G9 y% L- m4 |6 [: z9 ?; ~
not-allowed:无效光标
& z* x6 g a. N9 I8 Ohelp:?帮助光标
) l4 w% W& [) e% g M0 u) Xall-scroll:三角方向标
5 t5 O5 a. x( ^7 i- `! r. Vmove:移动标: z3 H. Z" o+ n5 @) q/ [# ^) Q
crosshair:十字标2 h; j- H, i% z5 N/ Y$ f, L& d
e-resize
# V7 p& b" ]# Z# D9 \) a( K. L4 kn-resize
! O4 e6 i/ B* ? W' {nw-resize& t! b; I; b3 L% G
w-resize" v+ a! q7 {3 Z3 d' k" l5 D
s-resize7 B- d/ O5 q$ B& t! q
se-resize
- R/ G2 s& S0 i+ d& fsw-resize
- n7 i$ r% i1 U
( V) G5 y/ V5 p1.本地无缓存,每次自动刷新
/ u3 |$ ?+ s3 ? O% Bresponse.expires=0
6 L/ P. \/ |4 K: t& q# Nresponse.addHeader"pragma","no-cache"# [& a0 \& d# i9 r6 ^
response.addHeader"cache-control","private"
6 d; U r$ b' C2 ]0 K3 U: \6 p; E! T2 l G" C- t ~6 y
2.修改contentType并下载gif等格式1 b8 p4 Z* }! h
<%
5 @6 D; w+ L. R- r' Jfunctiondl(f,n)
7 a$ K/ r) e( D/ Qonerrorresumenext) J4 U+ g# U% [/ f; j
$ h: s; S: `' q* }sets=CreateObject("Adodb.Stream")
( v) c3 _/ k: }) a, `* d0 u( CS.Mode=3$ S( s5 }5 Q8 M$ r S! A
S.Type=1
' Y8 |( \3 h0 w, w3 fS.Open
+ A# n* e! o, e; n1 u' `4 e2 ts.LoadFromFile(server.mappath(f))
$ Q$ V" B+ p- ?5 z% j1 [iferr.number>0then7 l4 ^$ _4 ?+ `! Q9 M e4 }
response.writeerr.number&":"&err.description4 l- w( g( g! N3 I$ O# x- q
else
0 J# t0 J- W- v" b r9 uresponse.contentType="application/x-gzip"
4 s3 _0 u, [7 C9 c( o$ ?) n# q* Cresponse.addheader"Content-Disposition:","attachment;filename="&n
8 C: I/ Y( B' f* e. J* V% qresponse.binarywrite(s.Read(s.size))" a& i4 D3 j( o& i5 J, k+ i
endif
3 p5 l0 e, N5 R; r, Vendfunction, G8 r- x% W' i; [" c" ]: e7 [
# ?* c | i3 r3 h* T. \6 a& l, m
calldl("012922501.gif","t1.gif")
" y7 O" R' [' ]4 ^0 W: n% H) |%>
6 R: \/ I0 B7 e) `0 @' k/ z, n7 G1 R
; X# F4 l5 ^& } C7 U5 n( Y# G19.检查一段字符串是否全由数字组成
* U6 \* H4 m q. {3 F+ {; T: X6 g<scriptlanguage="javascript"><!--
! i' c$ i, @8 v8 H; X% z( B2 efunctioncheckNum(str){return!/\D/.test(str)}
- y0 }! l L' E) z0 e- X0 [alert(checkNum("1232142141"))
) l- B) J" Z, W+ Nalert(checkNum("123214214a1"))" Y5 p8 P/ _2 Z. }$ m) R- U) a
//--></script>' k: e2 ?1 Y) U( u3 x
! n$ K( @9 U/ | k9 f' ~% d. k. d
20.获得一个窗口的大小
3 F: m* w% E. f! ]& Y3 T% Y Ndocument.body.clientWidth,document.body.clientHeight3 F+ |6 O$ I/ \0 N1 m
document.body.offsetWidth,document.body.offsetHeight3 u" b( F; c7 }1 Q* V Z
有时还需要知道window.screenTop,window.screenLeft
/ e9 t" W% U3 `' T! G1 k, T) s2 [ h8 n% i6 r
21.怎么判断是否含有汉字
+ `( C3 b5 q+ C, z8 Iif(escape(str).indexOf("%u")!=-1)alert("含有汉字");
7 N; Y2 Z$ z, K3 `elsealert("全是字符");0 [& W: O! g2 L
4 U# s+ e% L, i6 q, ?
22.TEXTAREA自适应文字行数的多少3 _+ w4 E& y1 L% j z& R
IE5.5+可以用overflow-y:visible
# v2 S: h; Y" c" {<textarearows=1name=s1cols=27style="overflow-y:visible">
8 P9 O+ H) s, ^) ?: H* o. ^, k U</textarea>
" i* D0 U9 ]& [5 k0 I0 }
/ N! E; n2 i" y2 S9 v23.日期减去天数等于第二个日期
5 ], W. b& N2 n3 q; q) ^<scriptlanguage=javascript>
! v4 h' j( m, ]: \functioncc(dd,dadd)
4 U H! K5 g3 l4 @+ i) H) H. p{
9 U6 e D3 M2 Q; A7 {) w b) e//可以加上错误处理3 o* A! \7 U( h9 { d- t3 L
vard=newDate(dd.replace("-","/"))4 c# V3 W7 ?8 a
d.setDate(d.getDate()+dadd)
* X4 A4 v" A3 k; e3 Ialert(d.getFullYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日")1 ^& h8 S# h2 ~! I5 i. f0 e( l
}+ w; \, e) f$ O6 {2 f
cc("2002-2-28",2)
. b3 ~6 ^3 y9 I* I</script> |
|