版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
-.z22条ASP初学者常用的代码1.获得系统时间:
<%=now()%>
2.取得来访用的IP:
<%=request.serverVariables("remote_host")%>
3.获得系统,浏览器版本:
<script>
window.document.write("版本:"+navigator.appName+navigator.appVersion+"browser.")
</script>
4.去除IE混动条:
<bodyscroll="no">
<bodystyle="overflow-y:hidden">
5.进入,跳出广告:
<scriptlanguage="javascript">
<!--
<!--注意更改文件所在路径-->
window.open(".selala./",","height=200,width=300,top=0,left=30");
//-->
</script>
6.随机数:
<%randomize%>
<%=(int(rnd()*n)+1)%>
N为可改变数
7.向上混动代码:
<marqueedirection="up"scrolldelay="200"style="font-size:9pt;color:*FF0000;
line-height:150%;font-style:italic;font-weight:bold"scrollamount="2"width="206"
height="207"bgcolor="*FFFF00">.selala./<;/marquee>
8.自动关闭网页:
<scriptLANGUAGE="javascript">
<!--
setTimeout("window.close();",10000);//60秒后关闭
//-->
</script>
<palign="center">本页10秒后自动关闭,请注意刷新页面</p>
9.随机背景音乐:
<%randomize%>
<bgsoundsrc="mids/<%=(int(rnd()*60)+1)%>.mid"loop="-1">
可以修改数字,限制调用个数,我这里是60个.
10.自动刷新本页面:
<script>
<!--
varlimit="0:10"
if(document.images){
varparselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
functionbeginrefresh(){
if(!document.images)
return
if(parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if(curmin!=0)
curtime=curmin+"分"+cursec+"秒后重刷本页!"
else
curtime=cursec+"秒后重刷本页!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
window.onload=beginrefresh
file://-->
</script>
11.ACCESS数据库连接:
<%
optione*plicit
dimstartime,endtime,conn,connstr,db
startime=timer()
''更改数据库名字
db="data/dvBBS5.mdb"
Setconn=Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath(db)
''如果你的效劳器采用较老版本Access驱动,请用下面连接方*
''connstr="driver={MicrosoftAccessDriver(*.mdb)};dbq="&Server.MapPath(db)
conn.Openconnstr
functionCloseDatabase
Conn.close
Setconn=Nothing
EndFunction
%>
12.SQL数据库连接:
<%
optione*plicit
dimstartime,endtime,conn,connstr,db
startime=timer()
connstr="driver={SQLServer};server=HUDENQ-N11T33NB;uid=sa;pwd=*sfeihu;database=dvbbs"
Setconn=Server.CreateObject("ADODB.Connection")
conn.Openconnstr
functionCloseDatabase
Conn.close
Setconn=Nothing
EndFunction
%>
13.用键盘翻开网页代码:
<scriptlanguage="javascript">
functionctlent(eventobject)
{
netif((event.ctrlKey&&window.event.keyCode==13)||(event.altKey&&window.event.keyCode==83))
{
window.open(''网址'',",")
}
}
</script>
这里是Ctrl+Enter和Alt+S的代码自己查下键盘的ASCII码再换就行
14.让层不被控件复盖代码:
<divz-Inde*:2><object***></object></div>#前面
<divz-Inde*:1><object***></object></div>#后面
<divid="Layer2"style="position:absolute;top:40;width:400p*;height:95p*;z-inde*:2"><tableheight=100%width=100%
bgcolor="*ff0000"><tr><tdheight=100%width=100%></td></tr></table><iframewidth=0height=0></iframe></div>
<divid="Layer1"style="position:absolute;top:50;width:200p*;height:115p*;z-inde*:1"><iframeheight=100%width=100%
></iframe></div>
15.动网FLASH广告代码:
<objectclassid="clsid27CDB6E-AE6D-11cf-96B8-0"
codebase="download.macromedia./pub/shockwave/cabs/flash/swflash.cab*version=5,0,0,0"width="468"
height="60"><paramname=movievalue="images/yj16d.swf"><paramname=qualityvalue=high><embed
src="images/dvbanner.swf"quality=highpluginspage=".macromedia./shockwave/download/inde*.cgi?
P1_Prod_Version=ShockwaveFlash";;;type="application/*-shockwave-flash"width="468"height="60"></embed></object>
16.VBS弹出窗口小代码:
<scriptlanguage=vbscript>
msgbo*"你还没有注册或登陆论坛","0","精品论坛"
location.href="login.asp"
</script>
16.使用FSO修改文件特定内容的函数
functionFSOchange(filename,Target,String)
DimobjFSO,objCountFile,FiletempData
SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
SetobjCountFile=objFSO.OpenTe*tFile(Server.MapPath(filename),1,True)
FiletempData=objCountFile.ReadAll
objCountFile.Close
FiletempData=Replace(FiletempData,Target,String)
SetobjCountFile=objFSO.CreateTe*tFile(Server.MapPath(filename),True)
objCountFile.WriteFiletempData
objCountFile.Close
SetobjCountFile=Nothing
SetobjFSO=Nothing
EndFunction
17.使用FSO读取文件内容的函数
functionFSOFileRead(filename)
DimobjFSO,objCountFile,FiletempData
SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
SetobjCountFile=objFSO.OpenTe*tFile(Server.MapPath(filename),1,True)
FSOFileRead=objCountFile.ReadAll
objCountFile.Close
SetobjCountFile=Nothing
SetobjFSO=Nothing
EndFunction
18.使用FSO读取文件*一行的函数
functionFSOlinedit(filename,lineNum)
iflinenum<1thene*itfunction
dimfso,f,temparray,tempt
setfso=server.CreateObject("scripting.filesystemobject")
ifnotfso.fileE*ists(server.mappath(filename))thene*itfunction
setf=fso.opente*tfile(server.mappath(filename),1)
ifnotf.AtEndofStreamthen
tempt=f.readall
f.close
setf=nothing
temparray=split(tempt,chr(13)&chr(10))
iflineNum>ubound(temparray)+1then
e*itfunction
else
FSOlinedit=temparray(lineNum-1)
endif
endif
endfunction
19.使用FSO写文件*一行的函数
functionFSOlinewrite(filename,lineNum,Linecontent)
iflinenum<1thene*itfunction
dimfso,f,temparray,tempt
setfso=server.CreateObject("scripting.filesystemobject")
ifnotfso.fileE*ists(server.mappath(filename))thene*itfunction
setf=fso.opente*tfile(server.mappath(filename),1)
ifnotf.AtEndofStreamthen
tempt=f.readall
f.close
temparray=split(tempt,chr(13)&chr(10))
iflineNum>ubound(temparray)+1then
e*itfunction
else
temparray(lineNum-1)=lineContent
endif
tempt=join(temparray,chr(13)&chr(10))
setf=fso.createte*tfile(server.mappath(filename),true)
f.writetempt
endif
f.close
esetf=nothing
endfunction
20.使用FSO添加文件新行的函数
functionFSOappline(filename,Linecontent)
dimfso,f
setfso=server.CreateObject("scripting.filesystemobject")
ifnotfso.fileE*ists(server.mappath(filename))thene*itfunction
setf=fso.opente*tfile(server.mappath(filename),8,1)
f.writechr(13)&chr(10)&Linecontent
f.close
setf=nothing
endfunction
21检测*个的速度:
把如下代码参加<body>区域中:
<scriptlanguage=javascript>
tim=1
setInterval("tim++",100)
b=1
varautourl=newArray()
autourl[1]=".selala./"
autourl[2]="selala./"
autourl[3]="./"
autourl[4]="/"
autourl[5]=".36963./"
functionbutt(){
document.write("<formname=autof>")
for(vari=1;i<autourl.length;i++)
document.write("<inputtype=te*tname=t*t"+i+"size=10value=测试中……>=?<inputtype=te*tname=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]["t*t"+b].value="/超时"}
else
{document.forms[0]["t*t"+b].value="时间"+tim/10+"秒"}
b++
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 分级护理的护理伦理与法律
- 骨科护理课程总结与展望
- 应急护理中的重症监护技术
- 高血压肾病的心理护理与支持
- 美术学考中职试题及答案
- 船舶帆缆工诚信道德模拟考核试卷含答案
- 合成气装置操作工班组管理强化考核试卷含答案
- 人教版语文五年级下册教案+反思 第六单元
- 混凝土机械装配调试工安全素养评优考核试卷含答案
- 电工合金电触头制造工复测评优考核试卷含答案
- 医院手术室净化及装饰工程施工方案设计
- 周仲瑛教授治疗外感咳嗽心要(新)
- 家长写给高三孩子的一封信范文
- 慢性肾脏病矿物质及骨代谢异常
- (正式版)SHT 3078-2024 立式圆筒形料仓工程设计规范
- JC∕T 60016-2022 建筑用免拆复合保温模板应用技术规程
- 理财知识及运用智慧树知到期末考试答案2024年
- 国开2024年《钢结构(本)》阶段性学习测验1-4答案
- 中医四诊在骨科评估中应用护理课件
- 沈阳恒昌塑料制品厂建设项目环境影响报告
- 准噶尔盆地西北缘地层表及地质符
评论
0/150
提交评论