整理了一些ASP初学者常用的代码Word文档下载推荐.docx
《整理了一些ASP初学者常用的代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《整理了一些ASP初学者常用的代码Word文档下载推荐.docx(17页珍藏版)》请在冰豆网上搜索。
marquee
direction="
up"
scrolldelay="
200"
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.自动关闭网页:
LANGUAGE="
setTimeout('
window.close();
10000);
//60秒后关闭
p
align="
center"
本页10秒后自动关闭,请注意刷新页面<
/p>
9.随机背景音乐:
bgsound
src="
mids/<
%=(int(rnd()*60)+1)%>
.mid"
loop="
-1"
可以修改数字,限制调用个数,我这里是60个.
10.自动刷新本页面:
var
limit="
0:
10"
if
(document.images){
parselimit=limit.split("
:
parselimit=parselimit[0]*60+parselimit[1]*1
}
function
beginrefresh(){
(!
document.images)
return
(parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
(curmin!
=0)
curtime=curmin+"
分"
+cursec+"
秒后重刷本页!
else
curtime=cursec+"
window.status=curtime
setTimeout("
beginrefresh()"
1000)
window.onload=beginrefresh
file:
//-->
11.ACCESS数据库连接:
%
option
explicit
dim
startime,endtime,conn,connstr,db
startime=timer()
更改数据库名字
db="
data/dvBBS5.mdb"
Set
conn
=
Server.CreateObject("
ADODB.Connection"
connstr="
Provider=Microsoft.Jet.OLEDB.4.0;
Data
Source="
&
Server.MapPath(db)
如果你的服务器采用较老版本Access驱动,请用下面连接方法
driver={Microsoft
Access
Driver
(*.mdb)};
dbq="
conn.Open
connstr
CloseDatabase
Conn.close
Nothing
End
Function
%>
12.SQL数据库连接:
driver={SQL
Server};
server=HUDENQ-N11T33NB;
uid=sa;
pwd=xsfeihu;
database=dvbbs"
13.用键盘打开网页代码:
ctlent(eventobject)
{
if((event.ctrlKey
window.event.keyCode==13)││(event.altKey
window.event.keyCode==83))
网址'
这里是Ctrl+Enter和Alt+S的代码
自己查下键盘的ASCII码再换就行
14.让层不被控件复盖代码:
div
z-Index:
2>
object
***>
/object>
/div>
#
前面
1>
后面
id="
Layer2"
position:
absolute;
top:
40;
width:
400px;
height:
95px;
z-index:
table
height=100%
width=100%
#ff0000"
tr>
td
width=100%>
/td>
/tr>
/table>
iframe
width=0
height=0>
/iframe>
Layer1"
50;
200px;
115px;
1"
15.动网FLASH广告代码:
classid="
clsid27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="
468"
60"
param
name=movie
value="
images/yj16d.swf"
name=quality
value=high>
embed
images/dvbanner.swf"
quality=high
pluginspage="
type="
application/x-shockwave-flash"
/embed>
16.vbs弹出窗口小代码:
language=vbscript>
msgbox"
你还没有注册或登陆论坛"
"
0"
精品论坛"
location.href
login.asp"
16.使用FSO修改文件特定内容的函数
FSOchange(filename,Target,String)
Dim
objFSO,objCountFile,FiletempData
objFSO
scripting.FileSystemObject"
objCountFile
objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FiletempData
objCountFile.ReadAll
objCountFile.Close
FiletempData=Replace(FiletempData,Target,String)
objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)
objCountFile.Write
objCountFile=Nothing
17.使用FSO读取文件内容的函数
FSOFileRead(filename)
FSOFileRead
18.使用FSO读取文件某一行的函数
FSOlinedit(filename,lineNum)
linenum
1
then
exit
fso,f,temparray,tempcnt
set
fso
server.CreateObject("
scripting.filesystemobject"
not
fso.fileExists(server.mappath(filename))
f
fso.opentextfile(server.mappath(filename),1)
f.AtEndofStream
tempcnt
f.readall
f.close
nothing
temparray
split(tempcnt,chr(13)&
chr(10))
lineNum>
ubound(temparray)+1
FSOlinedit
temparray(lineNum-1)
end
19.使用FSO写文件某一行的函数
FSOlinewrite(filename,lineNum,Linecontent)
fso,f,temparray,tempCnt
lineContent
join(temparray,chr(13)&
fso.createtextfile(server.mappath(filename),true)
f.write
20.使用FSO添加文件新行的函数
FSOappline(filename,Linecontent)
fso,f
fso.opentextfile(server.mappath(filename),8,1)
chr(13)&
chr(10)&
Linecontent
21.读文件最后一行的函数
FSOlastline(filename)
FSOlastline
temparray(ubound(temparray))
利用FSO取得BMP,JPG,PNG,GIF文件信息(大小,宽、高等)
BMP,
GIF,
JPG
and
PNG
This
gets
a
specified
number
of
bytes
from
any
file,
starting
at
the
offset
(base
1)
Passed:
flnm
=>
Filespec
file
to
read
Offset
which
start
reading
How
many
GetBytes(flnm,
offset,
bytes)
objFTemp
objTextStream
lngSize
on
error
resume
next
CreateObject("
)
First,
we
get
filesize
objFSO.GetFile(flnm)
objFTemp.Size
fsoForReading
objFSO.OpenTextFile(flnm,
fsoForReading)
0
strBuff
objTextStream.Read(offset
-
-1
Get
All!
GetBytes
objTextStream.Read(lngSize)
ReadAll
objTextStream.Read(bytes)
objTextStream.Close
function
Functions
convert
two
numeric
value
(long)
(both
little-endian
big-endian)
lngConvert(strTemp)
lngConvert
clng(asc(left(strTemp,
1))
+
((asc(right(strTemp,
*
256)))
lngConvert2(strTemp)
lngConvert2
clng(asc(right(strTemp,
((asc(left(strTemp,
does
most
real
work.
It
will
attempt
regardless
extension,
identify
it
is
graphical
image.
width
image
height
depth
color
(in
colors)
strImageType=>
type
(e.g.
etc.)
gfxSpex(flnm,
width,
height,
depth,
strImageType)
strPNG
strGIF
strBMP
strType
strImageType
(unknown)"
gfxSpex
False
chr(137)
chr(80)
chr(78)
GIF"
chr(66)
chr(77)
0,
3)
GIF
Width
lngConvert(GetBytes(flnm,
7,
2))
Height
9,
Depth
2
^
((asc(GetBytes(flnm,
11,
7)
True
elseif
left(strType,
2)
BMP
BMP"
19,
23,
(asc(GetBytes(flnm,
29,
1)))
Is
PNG"
lngConvert2(GetBytes(flnm,
Depth