分享
 
 
 

ASP精华问题3

王朝asp·作者佚名  2006-12-16
窄屏简体版  字體: |||超大  

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有