28.检测某个网站的链接速度:
把如下代码加入<body>区域中:
<scriptlanguage=javascript>
tim=1
setinterval("tim++",100)
b=1
varautourl=newarray()
autourl[1]="< src="pic/url.gif" align=absmiddle border=0>http://www.njcatv.net/"
autourl[2]="javacool.3322.net"
autourl[3]="< src="pic/url.gif" align=absmiddle border=0>http://www.sina.com.cn/"
autourl[4]="www.nuaa.edu.cn"
autourl[5]="< src="pic/url.gif" align=absmiddle border=0>http://www.cctv.com/"
functionbutt(){
document.write("<formname=autof>")
for(vari=1;i<autourl.length;i++)
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/>")
document.write("<inputtype=submitvalue=刷新></form>")
}
butt()
functionauto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="链接超时"}
else
{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
b++
}
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+")>")}
run()</script>
29.各种样式的光标
auto:标准光标
default:标准箭头
hand:手形光标
wait:等待光标
text:i形光标
vertical-text:水平i形光标
no-drop:不可拖动光标
not-allowed:无效光标
help:?帮助光标
all-scroll:三角方向标
move:移动标
crosshair:十字标
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize
30.本地无缓存,每次自动刷新
response.expires=0
response.addheader"pragma","no-cache"
response.addheader"cache-control","private"
31.修改contenttype并下载gif等格式
<%
functiondl(f,n)
onerrorresumenext
sets=createobject("adodb.stream")
s.mode=3
s.type=1
s.open
s.loadfromfile(server.mappath(f))
iferr.number>0then
response.writeerr.number&":"&err.description
else
response.contenttype="application/x-gzip"
response.addheader"content-disposition:","attachment;filename="&n
response.binarywrite(s.read(s.size))
endif
endfunction
calldl("012922501.gif","t1.gif")
%>
32.检查一段字符串是否全由数字组成
<scriptlanguage="javascript"><!--
functionchecknum(str){return!/\d/.test(str)}
alert(checknum("1232142141"))
alert(checknum("123214214a1"))
//--></script>
33.获得一个窗口的大小
document.body.clientwidth,document.body.clientheight
document.body.offsetwidth,document.body.offsetheight
有时还需要知道window.screentop,window.screenleft
34.怎么判断是否含有汉字
if(escape(str).indexof("%u")!=-1)alert("含有汉字");
elsealert("全是字符");
35.textarea自适应文字行数的多少
ie5.5+可以用overflow-y:visible
<textarearows=1name=s1cols=27style="overflow-y:visible">
</textarea>
36.日期减去天数等于第二个日期
<scriptlanguage=javascript>
functioncc(dd,dadd)
{
//可以加上错误处理
vard=newdate(dd.replace("-","/"))
d.setdate(d.getdate()+dadd)
alert(d.getfullyear()+"年"+(d.getmonth()+1)+"月"+d.getdate()+"日")
}
cc("2002-2-28",2)
</script>