欢迎光临
我们一直在努力

ASP常见问题及解答(3)-ASP教程,ASP技巧

建站超值云服务器,限时71元/月

1.图片显示控制:

<script language="javascript">

<!–

var flag=false;

function drawimage(imgd){

var image=new image();

image.src=imgd.src;

if(image.width>0 && image.height>0){

flag=true;

if(image.width/image.height>= 360/270){

if(image.width>360){

imgd.width=360;

imgd.height=(image.height*360)/image.width;

}else{

imgd.width=image.width;

imgd.height=image.height;

}

imgd.alt=image.width+"×"+image.height;

}

else{

if(image.height>270){

imgd.height=270;

imgd.width=(image.width*270)/image.height;

}else{

imgd.width=image.width;

imgd.height=image.height;

}

imgd.alt=image.width+"×"+image.height;

}

}

}

//–>

</script>

调用格式:

<img src="a.gif" onload="javascript:drawimage(this);"

2.用asp把doc转换成html

doc2html.vbs

**********************************************************

调用方法:doc2html c:\doc2html c:\doc2html

调用方法:doc2html -s c:\doc2html\a.doc c:\doc2html

**********************************************************

dim objword

dim objdoc

dim objfso

dim strsource

dim strtarget

dim bbatch

得到命令行参数,有三种可能的格式:[-s] 要进行转换的源文件目录或文件 转换成html文件后保存的目录

function getparams()

dim objarg

if wscript.arguments.count >= 2 then

if wscript.arguments.item(0) = "-s" or wscript.arguments.item(0) = "-s" then

strsource = wscript.arguments.item(1)

strtarget = wscript.arguments.item(2)

bbatch = false

else

strsource = wscript.arguments.item(0)

strtarget = wscript.arguments.item(1)

bbatch = true

end if

else

wscript.quit(1)

end if

end function

function batchprocessing()

dim objfolder

dim objfile

dim lpos

dim strfilename

lpos = 0

set objfolder = objfso.getfolder(strsource)

for each objfile in objfolder.files

lpos = instr(1,mid(objfile.path,len(objfile.path) – 3,4),"doc",1)

if lpos > 0 then

strfilename = objfso.getbasename(objfile.path)

wordinterface objfile.path,strfilename

end if

next

end function

function singleprocessing()

dim objfile

set objfile = objfso.getfile(strsource)

strfilename = objfso.getbasename(objfile.path)

wordinterface objfile.path,strfilename

end function

function wordinterface(strfilename,formattedfilename)

objword.documents.open strfilename

set objdoc = objword.activedocument

stop

set the title of the document to match the filename

objdoc.builtindocumentproperties(1) = formattedfilename

1 = wdpropertytitle in vba

objdoc.saveas strtarget & "\" & formattedfilename & ".htm",8

objdoc.saveas "c:\doc2html\" & formattedfilename & ".htm",8

on error resume next

objdoc.close

end function

stop

set objfso = createobject("scripting.filesystemobject")

set objword = createobject("word.application")

objword.visible = false

call getparams

if bbatch then

call batchprocessing

else

call singleprocessing

end if

objword.quit

set objword = nothing

3.自己写的将小写金额换成大写

<%

****人民币大小写转换格式****

dim str(9)

str(0)="零"

str(1)="壹"

str(2)="贰"

str(3)="叁"

str(4)="肆"

str(5)="伍"

str(6)="陆"

str(7)="柒"

str(8)="捌"

str(9)="玖"

aa=request.form("source")

hh=formatnumber(aa,2,-1)

aa=replace(hh,".","")

aa=replace(aa,",","")

for i=1 to len(aa)

s=mid(aa,i,1)

mynum=str(s)

select case(len(aa)+1-i)

case 1: k= mynum&"分"

case 2: k= mynum&"角"

case 3: k= mynum&"元"

case 4: k= mynum&"拾"

case 5: k= mynum&"佰"

case 6: k= mynum&"仟"

case 7: k= mynum&"万"

case 8: k= mynum&"拾"

case 9: k= mynum&"佰"

case 10: k= mynum&"仟"

end select

m=m&k

next

%>

<html>

<head>

<title>数字转换</title>

<meta http-equiv="content-type" content="text/html; charset=gb2312">

</head>

<!–

elseif(s=".") then

n=m

i=i+2

for j=i to len(aa)

s=mid(aa,i,1)

mynum=str(s)

select case(len(aa)+1-i)

case 1: p= mynum&"分"

case 2: p= mynum&"角"

end select

m=m&p

next

–>

<body bgcolor="#ffffff">

<form method="post" name="forma">

<input type="text" name="source" value="<%=hh%>">

=

<input type="text" name="result" value="<%=m%>" size="40">

<input type="submit" name="submit" value="提交 " >

</form>

</body>

</html>

4.获取中文字符串拼音首字母串的函数

<%

response.write "<link href=style.css rel=stylesheet>"

if request.form("content")="" then

response.write "<center><form method=post action=""""><input name=content type=text>__<input type=submit></form>"

else

function getpychar(char)

tmp=65536+asc(char)

if(tmp>=45217 and tmp<=45252) then

getpychar= "a"

elseif(tmp>=45253 and tmp<=45760) then

getpychar= "b"

elseif(tmp>=45761 and tmp<=46317) then

getpychar= "c"

elseif(tmp>=46318 and tmp<=46825) then

getpychar= "d"

elseif(tmp>=46826 and tmp<=47009) then

getpychar= "e"

elseif(tmp>=47010 and tmp<=47296) then

getpychar= "f"

elseif(tmp>=47297 and tmp<=47613) then

getpychar= "g"

elseif(tmp>=47614 and tmp<=48118) then

getpychar= "h"

elseif(tmp>=48119 and tmp<=49061) then

getpychar= "j"

elseif(tmp>=49062 and tmp<=49323) then

getpychar= "k"

elseif(tmp>=49324 and tmp<=49895) then

getpychar= "l"

elseif(tmp>=49896 and tmp<=50370) then

getpychar= "m"

elseif(tmp>=50371 and tmp<=50613) then

getpychar= "n"

elseif(tmp>=50614 and tmp<=50621) then

getpychar= "o"

elseif(tmp>=50622 and tmp<=50905) then

getpychar= "p"

elseif(tmp>=50906 and tmp<=51386) then

getpychar= "q"

elseif(tmp>=51387 and tmp<=51445) then

getpychar= "r"

elseif(tmp>=51446 and tmp<=52217) then

getpychar= "s"

elseif(tmp>=52218 and tmp<=52697) then

getpychar= "t"

elseif(tmp>=52698 and tmp<=52979) then

getpychar= "w"

elseif(tmp>=52980 and tmp<=53640) then

getpychar= "x"

elseif(tmp>=53689 and tmp<=54480) then

getpychar= "y"

elseif(tmp>=54481 and tmp<=62289) then

getpychar= "z"

else 如果不是中文,则不处理

getpychar=char

end if

end function

function getpy(str)

for i=1 to len(str)

getpy=getpy&getpychar(mid(str,i,1))

next

end function

content=request.form("content")

response.write "<center>"&getpy(content)&chr(10)

response.write "<br/><br/><br/><a href=# onclick=javascript:history.go(-1)>返回</a>"

end if

%>

5.ip限制函数

******************************

function checkip(cinput_ip,cbound_ip)

created by qqdao, qqdao@263.net 2001/11/28

说明:首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内

参数: cinput_ip,代检查的ip

cbound_ip,给定的范围格式为,单个ip,和范围ip,范围ip最后使用”-“分割,如果是“*”则必须放到最后一位

每个范围后添加":allow"表示允许登陆,添加":refuse"表示拒绝登陆。多个范围用”;“隔开

例如192.168.1*.*:allow;192.168.1.1:allow;192.168.1.1-10:refuse"

返回值: true/false

更新:2001/12/05 支持allow,refuse支持’*‘,不想对?支持,因为和*差不多

******************************

function checkip(cinput_ip,cbound_ip)

dim csingle_ip,ctemp_ip,cstart_ip,cend_ip

checkip = false

csingle_ip=split(cbound_ip,";")

for i=0 to ubound(csingle_ip)

if instr(csingle_ip(i),"refuse") <> 0 then 就是拒绝了

ctemp_ip = left(csingle_ip(i),instr(csingle_ip(i),":")-1)

if instr(ctemp_ip,"*") <> 0 then 是宽范围

cstart_ip = left(ctemp_ip,instr(ctemp_ip,"*")-1)

if left(cinput_ip,len(cstart_ip))=cstart_ip then

checkip = false

exit function

end if

end if

if instr(ctemp_ip,"-") = 0 then

cstart_ip = ctemp_ip

cend_ip = ctemp_ip

else

cstart_ip = left(ctemp_ip,instr(ctemp_ip,"-")-1)

cend_ip = left(cstart_ip,instrrev(cstart_ip,".")-1)+"."+mid(ctemp_ip,instr(ctemp_ip,"-")+1)

end if

if ip2str(cinput_ip)>=ip2str(cstart_ip) and ip2str(cinput_ip)<=ip2str(cend_ip) then

checkip = false

exit function

end if

elseif instr(csingle_ip(i),"allow") <> 0 then 允许

ctemp_ip = left(csingle_ip(i),instr(csingle_ip(i),":")-1)

if instr(ctemp_ip,"*") <> 0 then 是宽范围

cstart_ip = left(ctemp_ip,instr(ctemp_ip,"*")-1)

if left(cinput_ip,len(cstart_ip))=cstart_ip then

checkip = true

end if

end if

if instr(ctemp_ip,"-") = 0 then

cstart_ip = ctemp_ip

cend_ip = ctemp_ip

else

cstart_ip = left(ctemp_ip,instr(ctemp_ip,"-")-1)

cend_ip = left(cstart_ip,instrrev(cstart_ip,".")-1)+"."+mid(ctemp_ip,instr(ctemp_ip,"-")+1)

end if

if ip2str(cinput_ip)>=ip2str(cstart_ip) and ip2str(cinput_ip)<=ip2str(cend_ip) then

checkip =true

else

checkip =false

end if

end if

next

end function

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP常见问题及解答(3)-ASP教程,ASP技巧
分享到: 更多 (0)

相关推荐

  • 暂无文章