Simple and practical ASP programming code Comparison table

Source: Internet
Author: User
Tags exit chr comparison end functions sql split version
Programming 1. Access to System time:

<%=now ()%>

2. Access to the IP:

<%=request.servervariables ("Remote_host")%>

3. Access to the system, browser version:

<script>

Window.document.write ("Version:" +navigator.appname+navigator.appversion+ "browser.")

</script>

4. Remove IE mixing strips:

<body scroll= "No" >

<body style= "Overflow-y:hidden" >

5. Go to the website and jump out of the advertisement:

<script language= "JavaScript" >

<!--

<!--note change the path to the file-->

window.open (' http://www.XXXXXX.com ', ', ', ', ', ' height=200,width=300,top=0,left=30 ');

-->

</script>

6. Random Number:

<%randomize%>

<%= (int (rnd () *n) +1)%>

N is a number that can be changed

7. Move Up code:

<marquee direction= "Up" scrolldelay= "style=" FONT-SIZE:9PT; Color: #FF0000;

line-height:150%; Font-style:italic; Font-weight:bold "scrollamount=" 2 "width=" 206 "

height= "207" bgcolor= "#FFFF00" >hhhhhhhhhhhhhhhhhhh</marquee>

8. Automatically close the Web page:

<script language= "JavaScript" >

<!--

SetTimeout (' Window.close (); ', 10000); Shut down in 60 seconds.

-->

</script>

<p align= "Center" > this page closes automatically after 10 seconds, please note refresh page </p>

9. Random background music:

<%randomize%>

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

Can modify the number, limit the number of calls, I am here 60.

10. Automatically refresh this page:

<script>

<!--

var limit= "0:10"

if (document.images) {

var parselimit=limit.split (":")

Parselimit=parselimit[0]*60+parselimit[1]*1

}

function Beginrefresh () {

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+" seconds after the brush this page! "

Else

curtime=cursec+ "Seconds later to brush this page!" "

Window.status=curtime

SetTimeout ("Beginrefresh ()", 1000)

}

}

Window.onload=beginrefresh

File://-->

</script>

11.ACCESS Database connection:

<%

Option Explicit

Dim startime,endtime,conn,connstr,db

Startime=timer ()

' Change database name

db= "Data/dvbbs5.mdb"

Set conn = Server.CreateObject ("ADODB. Connection ")

Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DB)

' If your server is powered by an older version of Access, use the following connection method

' connstr= ' driver={Microsoft Access driver (*.mdb)};d bq= "& Server.MapPath (DB)

Conn. Open ConnStr

function CloseDatabase

Conn.close

Set conn = Nothing

End Function

%>

12.SQL Database connection:

<%

Option Explicit

Dim startime,endtime,conn,connstr,db

Startime=timer ()

connstr= "driver={SQL Server};server=hudenq-n11t33nb;uid=sa;pwd=xsfeihu;database=dvbbs"

Set conn = Server.CreateObject ("ADODB. Connection ")

Conn. Open ConnStr

function CloseDatabase

Conn.close

Set conn = Nothing

End Function

%>

13. Open the page code with the keyboard:

<script language= "JavaScript" >

function Ctlent (eventobject)

{

if ((Event.ctrlkey && window.event.keycode==13) | | (Event.altkey && window.event.keycode==83))

{

window.open (' url ', ', ', ')

}

}

</script>

This is Ctrl+enter and Alt+s's code. Check the ASCII code of the keyboard and change it.

14. Let the layer not be covered by the control code:

<div Z-index:2><object ***></object></div> # Front

<div Z-index:1><object ***></object></div> # behind

<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>

<div id= "Layer1" style= "Position:absolute; top:50;width:200px;
Height:115px;z-index:1 "><iframe height=100%
Width=100%></iframe></div>

15. Dynamic Network Flash Advertising code:

<object classid= "clsid27cdb6e-ae6d-11cf-96b8-444553540000"
Codebase= " http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0 "
"468" height= "width=" ><param Name=movie
Value= "images/yj16d.swf" ><param name=quality
value=high><embed src= "http://www.webjx.com/htmldata/2005-06-13/images/dvbanner.swf" Quality=high
Pluginspage= " Http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash ";;;
Type= "Application/x-shockwave-flash" width= "468"
height= "></embed></object>"

16.VBS Pop-up window small code:

<script language=vbscript>

MsgBox "You haven't registered or landed forum", "0", "Boutique Forum"

Location.href = "Login.asp"

</script>

16. Functions to modify file-specific content using the FSO

function Fsochange (filename,target,string)

Dim Objfso,objcountfile,filetempdata

Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")

Set objcountfile = objFSO.OpenTextFile (Server.MapPath (filename), 1,true)

Filetempdata = Objcountfile.readall

Objcountfile.close

Filetempdata=replace (filetempdata,target,string)

Set objcountfile=objfso.createtextfile (Server.MapPath (filename), True)

Objcountfile.write Filetempdata

Objcountfile.close

Set objcountfile=nothing

Set objFSO = Nothing

End Function

17. Functions to read the contents of a file using the FSO

function fsofileread (filename)

Dim Objfso,objcountfile,filetempdata

Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")

Set objcountfile = objFSO.OpenTextFile (Server.MapPath (filename), 1,true)

Fsofileread = Objcountfile.readall

Objcountfile.close

Set objcountfile=nothing

Set objFSO = Nothing

End Function

18. Function to read a row of a file using the FSO

function Fsolinedit (filename,linenum)

If LineNum < 1 then Exit function

Dim fso,f,temparray,tempcnt

Set fso = server. CreateObject ("Scripting.FileSystemObject")

If not fso.fileexists (Server.MapPath (filename)) then Exit function

Set F = fso.opentextfile (Server.MapPath (filename), 1)

If not F.atendofstream then

tempcnt = F.readall

F.close

Set F = Nothing

Temparray = Split (TEMPCNT,CHR) &AMP;CHR (10))

If Linenum>ubound (temparray) +1 Then

Exit function

Else

Fsolinedit = Temparray (lineNum-1)

End If

End If

End Function

19. Use the FSO to write a row of a file function

function Fsolinewrite (filename,linenum,linecontent)

If LineNum < 1 then Exit function

Dim fso,f,temparray,tempcnt

Set fso = server. CreateObject ("Scripting.FileSystemObject")

If not fso.fileexists (Server.MapPath (filename)) then Exit function

Set F = fso.opentextfile (Server.MapPath (filename), 1)

If not F.atendofstream then

tempcnt = F.readall

F.close

Temparray = Split (TEMPCNT,CHR) &AMP;CHR (10))

If Linenum>ubound (temparray) +1 Then

Exit function

Else

Temparray (lineNum-1) = Linecontent

End If

tempcnt = Join (TEMPARRAY,CHR) &AMP;CHR (10))

Set F = fso.createtextfile (Server.MapPath (filename), true)

F.write tempcnt

End If

F.close

Set F = Nothing

End Function

20. Function to add a new line of files using the FSO

function Fsoappline (filename,linecontent)

Dim fso,f

Set fso = server. CreateObject ("Scripting.FileSystemObject")

If not fso.fileexists (Server.MapPath (filename)) then Exit function

Set F = fso.opentextfile (Server.MapPath (filename), 8, 1)

F.write chr (&AMP;CHR) &linecontent

F.close

Set F = Nothing

End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.