【ASP】ASP初学者可方便查询相关的代码

1.获得系统时间:
None.gif < % = now ()% >

2.取得来访用的IP:

1 None.gif < %=request .serverVariables("remote_host")% >

3.获得系统,浏览器版本:
1 None.gif < script >
2 None.gifwindow.document.write("版本:"+navigator.appName+navigator.appVersion+" browser.")
3 None.gif </ script >

4.去除IE混动条:

1 None.gif < body  scroll ="no" >  
2 None.gif < body  style ="overflow-y:hidden" >

5.进入网站,跳出广告:

1 None.gif < script  language ="javascript" >
2 None.gif <!--  
3 None.gif<!-- 注意更改文件所在路径 -->
4 None.gifwindow.open(''http://www.XXXXXX.com&#39;','''',''height=200,width=300,top=0,left=30'');
5 None.gif// -->
6 None.gif </ script >
7 None.gif

6.随机数:
1 None.gif < %randomize % >
2 None.gif < %=(int (rnd()*n)+1)% >

N为可改变数

7.向上混动代码:

1 None.gif < marquee  direction ="up"  scrolldelay ="200"  style ="font-size: 9pt; color: #FF0000;
2 None.gifline-height: 150%; font-style:italic; font-weight:bold"  scrollamount ="2"  width ="206"
3 None.gifheight ="207"  bgcolor ="#FFFF00" > hhhhhhhhhhhhhhhhhhh </ marquee >
4 None.gif

8.自动关闭网页:

1 None.gif < script  LANGUAGE ="javascript" >
2 None.gif <!--
3 None.gifsetTimeout(''window.close();'', 10000); //60秒后关闭
4 None.gif//  -->
5 None.gif </ script >
6 None.gif < align ="center" > 本页10秒后自动关闭,请注意刷新页面 </ p >
7 None.gif

9.随机背景音乐:

1 None.gif < %randomize % >
2 None.gif < bgsound  src ="mids/<%=(int(rnd()*60)+1)%>.mid"  loop ="-1" >  
3 None.gif

可以修改数字,限制调用个数,我这里是60个.

10.自动刷新本页面:

 1 None.gif < script >  
 2 None.gif < ! --   
 3 None.gif 
 4 None.gifvar limit = " 0:10 "   
 5 None.gif 
 6 None.gif if  (document.images){ 
 7 None.gifvar parselimit = limit. split ( " : "
 8 None.gifparselimit = parselimit[ 0 ] * 60 + parselimit[ 1 ] * 1  
 9 None.gif } 
10 None.gif function  beginrefresh(){ 
11 None.gif if  (!document.images) 
12 None.gifreturn 
13 None.gif if  (parselimit == 1
14 None.gifwindow.location.reload() 
15 None.gif else
16 None.gifparselimit -= 1  
17 None.gifcurmin = Math.floor(parselimit / 60
18 None.gifcursec = parselimit% 60  
19 None.gif if  (curmin! = 0
20 None.gifcurtime = curmin + " " + cursec + " 秒后重刷本页! "  
21 None.gif else  
22 None.gifcurtime = cursec + " 秒后重刷本页! "  
23 None.gifwindow.status = curtime 
24 None.gifsetTimeout( " beginrefresh() " , 1000
25 None.gif
26 None.gif}  
27 None.gif
28 None.gifwindow.onload = beginrefresh 
29 None.giffile: //-->  
30 None.gif </ script >

11.ACCESS数据库连接:

 1 None.gif < %
 2 None.gif option   explicit
 3 None.gif dim  startime,endtime,conn,connstr,db
 4 None.gifstartime = timer ()
 5 None.gif ' 更改数据库名字
 6 None.gif db = " data/dvBBS5.mdb"
 7 None.gif Set  conn  =  Server. createObject ( " ADODB.Connection " )
 8 None.gifconnstr = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "   &  Server.MapPath(db)
 9 None.gif ' 如果你的服务器采用较老版本Access驱动,请用下面连接方*
10 None.gif' connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(db)
11 None.gif conn.Open connstr
12 None.gif function  CloseDatabase
13 None.gifConn.close
14 None.gif Set  conn  =   Nothing
15 None.gif End Function
16 None.gif% >
17 None.gif

12.SQL数据库连接:

 1 None.gif < %
 2 None.gif option   explicit
 3 None.gif dim  startime,endtime,conn,connstr,db
 4 None.gifstartime = timer ()
 5 None.gifconnstr = " driver={SQL Server};server=HUDENQ-N11T33NB;uid=sa;pwd=xsfeihu;database=dvbbs "  
 6 None.gif Set  conn  =  Server. createObject ( " ADODB.Connection " )
 7 None.gifconn.Open connstr
 8 None.gif function  CloseDatabase
 9 None.gifConn.close
10 None.gif Set  conn  =   Nothing
11 None.gif End Function
12 None.gif% >
13 None.gif

13.用键盘打开网页代码:

 1 None.gif < script language = " javascript " >
 2 None.gif function  ctlent(eventobject)
 3 None.gif{
 4 None.gif if ((event.ctrlKey  &&  window.event.keyCode == 13 ) || (event.altKey  &&  window.event.keyCode == 83 ))
 5 None.gif{
 6 None.gifwindow.open('网址','','')
 7 None.gif}
 8 None.gif}
 9 None.gif </ script >  
10 None.gif

这里是Ctrl+Enter和Alt+S的代码 自己查下键盘的ASCII码再换就行

14.让层不被控件复盖代码:

1 None.gif < div  z-Index:2 >< object  *** ></ object ></ div >  # 前面 
2 None.gif < div  z-Index:1 >< object  *** ></ object ></ div >  # 后面 
3 None.gif < div  id ="Layer2"  style ="position:absolute; top:40;width:400px; height:95px;z-index:2" >< table  height =100%  width =100%  bgcolor ="#ff0000" >< tr >< td  height =100%  width =100% ></ td ></ tr ></ table >< iframe  width =0  height =0 ></ iframe ></ div >
4 None.gif < div  id ="Layer1"  style ="position:absolute; top:50;width:200px; height:115px;z-index:1" >< iframe  height =100%  width =100% ></ iframe ></ div >
5 None.gif

15.动网FLASH广告代码:

1 None.gif < object  classid ="clsid27CDB6E-AE6D-11cf-96B8-444553540000"  codebase ="http://download.macromedia.com/p& dot.gif ;flash.cab#version=5,0,0,0"  width ="468"  height ="60" >< param  name =movie  value ="images/yj16d.swf" >< param  name =quality  value =high >< embed  src ="images/dvbanner.swf"  quality =high  pluginspage ="http://www.macromedia.com/shockw dot.gif kwaveFlash" ;;; type ="application/x-shockwave-f dot.gif height=" 60" ></ embed ></ object >

16.VBS弹出窗口小代码:
1 None.gif < script language = vbscript >
2 None.gif msgbox " 你还没有注册或登陆论坛 " , " 0 " , " 精品论坛"
3 None.gif location.href  =   " login.asp"
4 None.gif </ script >


16.使用FSO修改文件特定内容的函数

None.gif function  FSOchange(filename,Target, String )
None.gif
Dim  objFSO,objCountFile,FiletempData
None.gif
Set  objFSO  =  Server. createObject ( " Scripting.FileSystemObject " )
None.gif
Set  objCountFile  =  objFSO.OpenTextFile(Server.MapPath(filename), 1 , True )
None.gifFiletempData 
=  objCountFile.ReadAll
None.gifobjCountFile.Close
None.gifFiletempData
= Replace (FiletempData,Target, String )
None.gif
Set  objCountFile = objFSO.createTextFile(Server.MapPath(filename), True )
None.gifobjCountFile.Write FiletempData 
None.gifobjCountFile.Close
None.gif
Set  objCountFile = Nothing
None.gif
Set  objFSO  =   Nothing
None.gif
End Function
None.gif

17.使用FSO读取文件内容的函数

None.gif function  FSOFileRead(filename)
None.gif
Dim  objFSO,objCountFile,FiletempData
None.gif
Set  objFSO  =  Server. createObject ( " Scripting.FileSystemObject " )
None.gif
Set  objCountFile  =  objFSO.OpenTextFile(Server.MapPath(filename), 1 , True )
None.gifFSOFileRead 
=  objCountFile.ReadAll
None.gifobjCountFile.Close
None.gif
Set  objCountFile = Nothing
None.gif
Set  objFSO  =   Nothing
None.gif
End Function

18.使用FSO读取文件某一行的函数
None.gif function  FSOlinedit(filename,lineNum)
None.gif
if  linenum  <   1   then   exit   function
None.gif
dim  fso,f,temparray,tempcnt
None.gif
set  fso  =  server. createObject ( " scripting.filesystemobject " )
None.gif
if   not  fso.fileExists(server.mappath(filename))  then   exit   function
None.gif
set  f  =  fso.opentextfile(server.mappath(filename), 1 )
None.gif
if   not  f.AtEndofStream  then
None.giftempcnt 
=  f.readall
None.giff.close
None.gif
set  f  =   nothing
None.giftemparray 
=   split (tempcnt, chr ( 13 ) & chr ( 10 ))
None.gif
if  lineNum > ubound (temparray) + 1   then
None.gif
exit   function
None.gif
else
None.gifFSOlinedit 
=  temparray(lineNum - 1 )
None.gif
end   if
None.gif
end   if
None.gif
end function
None.gif

19.使用FSO写文件某一行的函数
None.gif function  FSOlinewrite(filename,lineNum,Linecontent)
None.gif
if  linenum  <   1   then   exit   function
None.gif
dim  fso,f,temparray,tempCnt
None.gif
set  fso  =  server. createObject ( " scripting.filesystemobject " )
None.gif
if   not  fso.fileExists(server.mappath(filename))  then   exit   function
None.gif
set  f  =  fso.opentextfile(server.mappath(filename), 1 )
None.gif
if   not  f.AtEndofStream  then
None.giftempcnt 
=  f.readall
None.giff.close
None.giftemparray 
=   split (tempcnt, chr ( 13 ) & chr ( 10 ))
None.gif
if  lineNum > ubound (temparray) + 1   then
None.gif
exit   function
None.gif
else
None.giftemparray(lineNum
- 1 =  lineContent
None.gif
end   if
None.giftempcnt 
=   join (temparray, chr ( 13 ) & chr ( 10 ))
None.gif
set  f  =  fso.createtextfile(server.mappath(filename), true )
None.giff.write tempcnt
None.gif
end   if
None.giff.close
None.gif
set  f  =   nothing
None.gif
end function
None.gif

20.使用FSO添加文件新行的函数

None.gif function  FSOappline(filename,Linecontent)
None.gif
dim  fso,f
None.gif
set  fso  =  server. createObject ( " scripting.filesystemobject " )
None.gif
if   not  fso.fileExists(server.mappath(filename))  then   exit   function
None.gif
set  f  =  fso.opentextfile(server.mappath(filename), 8 , 1 )
None.giff.write 
chr ( 13 ) & chr ( 10 ) & Linecontent
None.giff.close
None.gif
set  f  =   nothing
None.gif
end function
None.gif

转载于:https://www.cnblogs.com/fantboy/archive/2005/09/07/231681.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值