ASP常见问题及解答

1.如何 最小化、最大化、关闭窗口
答:<objectid=hh1classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="minimize"></object>
<objectid=hh2classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="maximize"></object>
<objectid=hh3classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="command"value="close"></object>

<inputtype=buttonvalue=最小化οnclick=hh1.click()>
<inputtype=buttonvalue=最大化οnclick=hh2.click()>
<inputtype=buttonvalue=关闭οnclick=hh3.click()>

2.如何静止页面缓存
答:htm网页
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache,must-revalidate">
<metahttp-equiv="expires"content="wed,26feb199708:21:57gmt">
或者<metahttp-equiv="expires"content="0">
asp网页
response.expires=-1
response.expiresabsolute=now()-1
response.cachecontrol="no-cache"
php网页
header("expires:mon,26jul199705:00:00gmt");
header("cache-control:no-cache,must-revalidate");
header("pragma:no-cache");

3.如何检查一段字符串是否全由数字组成
<scriptlanguage="javascript"><!--
functionchecknum(str){returnstr.match(//d/)==null}
alert(checknum("1232142141"))
alert(checknum("123214214a1"))
//--></script>

4.如何获取机器信息
答本机ip<%=request.servervariables("remote_addr")%>
服务器名<%=request.servervariables("server_name")%>
服务器ip<%=request.servervariables("local_addr")%>
服务器端口<%=request.servervariables("server_port")%>
服务器时间<%=now%>
iis版本<%=request.servervariables"server_software")%>
脚本超时时间<%=server.scripttimeout%>
本文件路径<%=server.mappath(request.servervariables("script_name"))%>
服务器cpu数量<%=request.servervariables("number_of_processors")%>
服务器解译引擎<%=scriptengine&"/" & scriptenginemajorversion &"." & scriptengineminorversion & "." & scriptenginebuildversion%>

1.如何让日期相减
日期减去天数等于第二个日期
<scriptlanguage=javascript>
functioncc(dd,dadd)
{
//可以加上错误处理
vard=newdate(dd.replace("-","/"))
d.setdate(d.getdate()+dadd)
alert(d.getfullyear()+"年"+(d.getmonth()+1)+"月"+d.getdate()+"日")
}
cc("2002-2-28",2)

1.怎样通过asp的手段来检查来访者是否用了代理
<%ifrequest.servervariables("http_x_forwarded_for")<>""then
response.write"<fontcolor=#ff0000>您通过了代理服务器,"&_
"真实的ip为"&request.servervariables("http_x_forwarded_for")
endif

1.如何实现连续滚动

<div id="marquees"><br/><br/>

数据里面读出来的<br/>
</div>

<script language="JavaScript">

marqueesHeight=200;
stopscroll=false;

with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
οnmοuseοver=new Function("stopscroll=true");
οnmοuseοut=new Function("stopscroll=false");
}
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');

preTop=0; currentTop=0;

function init(){
templayer.innerHTML="";
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval("scrollUp()",10);
}
document.body.οnlοad=init;

function scrollUp(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1;
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
}
}

只针对图片:

<form name=form1 οnsubmit="return mm()">
<input type=file name=meizz><br/>
<input type=submit value=submit></form>

<SCRIPT LANGUAGE="JavaScript"><!--
function mm()
{
var s = document.form1.meizz.value;
if(s=="")return false;
var img = new Image();
img.src = s;
alert("高 = "+ img.height + "/n宽 = "+ img.width);
alert("fileSize = "+ img.fileSize +" 字节");
return(img.fileSize <= 40000);
}


//--></SCRIPT>
</script>
%>
</script>
服务器操作系统<%=request.servervariables("os")%>
 
1. οncοntextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
<table border οncοntextmenu=return(false)><td>no</table> 可用于Table

2. <body onselectstart="return false"> 取消选取、防止复制

3. οnpaste="return false" 不准粘贴

4. οncοpy="return false;" oncut="return false;" 防止复制

5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标

6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标

7. <input style="ime-mode:disabled"> 关闭输入法

8. 永远都会带着框架
<script language="javascript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
// --></script>

9. 防止被人frame
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>

10. <noscript><iframe src=*.html></iframe></noscript> 网页将不能被另存为

11. <input type=button value=查看网页源代码
οnclick="window.location = 'view-source:'+ 'http://www.csdn.net/'">

12. 怎样通过asp的手段来检查来访者是否用了代理
<% if Request.ServerVariables("HTTP_X_FORWARDED_FOR")<>"" then
response.write "<font color=#FF0000>您通过了代理服务器,"& _
"真实的IP为"&Request.ServerVariables("HTTP_X_FORWARDED_FOR")
end if
%>

13. 取得控件的绝对位置

//javascript
<script language="javascript">
function getIE(e){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"/nleft="+l);
}
</script>

//VBScript
<script language="VBScript"><!--
function getIE()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while a.tagName<>"BODY"
set a = a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
--></script>

14. 光标是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart('character',e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" οnfοcus="cc()">

15. 判断上一页的来源
asp:
request.servervariables("HTTP_REFERER")

javascript:
document.referrer

16. 最小化、最大化、关闭窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" value="Close"></OBJECT>

<input type=button value=最小化 οnclick=hh1.Click()>
<input type=button value=最大化 οnclick=hh2.Click()>
<input type=button value=关闭 οnclick=hh3.Click()>
本例适用于IE

17.
<%
'定义数据库连接的一些常量
Const adOpenForwardOnly = 0 '游标只向前浏览记录,不支持分页、Recordset、BookMark
Const adOpenKeyset = 1 '键集游标,其他用户对记录说做的修改将反映到记录集中,但其他用户增加或删除记录不会反映到记录集中。支持分页、Recordset、BookMark
Const adOpenDynamic = 2 '动态游标功能最强,但耗资源也最多。用户对记录说做的修改,增加或删除记录都将反映到记录集中。支持全功能浏览(ACCESS不支持)。
Const adOpenStatic = 3 '静态游标,只是数据的一个快照,用户对记录说做的修改,增加或删除记录都不会反映到记录集中。支持向前或向后移动

Const adLockReadOnly = 1 '锁定类型,默认的,只读,不能作任何修改
Const adLockPessimistic = 2 '当编辑时立即锁定记录,最安全的方式
Const adLockOptimistic = 3 '只有在调用Update方法时才锁定记录集,而在此前的其他操作仍可对当前记录进行更改、插入和删除等
Const adLockBatchOptimistic = 4 '当编辑时记录不会被锁定,而更改、插入和删除是在批处理方式下完成的

Const adCmdText = &H0001
Const adCmdTable = &H0002
%>

18. 网页不会被缓存
HTM网页
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">
ASP网页
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
PHP网页
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

19. 检查一段字符串是否全由数字组成
<script language="javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>

20. 获得一个窗口的大小
document.body.clientWidth,document.body.clientHeight

21. 怎么判断是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");
else alert("全是字符");

22.TEXTAREA自适应文字行数的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
</textarea>

23. 日期减去天数等于第二个日期
<script language=javascript>
function cc(dd,dadd)
{
//可以加上错误处理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(a)
alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")
}
cc("12/23/2002",2)
</script>

24. 选择了哪一个Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>Style
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check" οnclick="checkme()">
</BODY></HTML>

25.获得本页url的request.servervariables("")集合
Response.Write "<TABLE border=1><!-- Table Header --><TR><TD><B>Variables</B></TD><TD><B>value</B></TD></TR>"
for each ob in Request.ServerVariables
Response.Write "<TR><TD>"&ob&"</TD><TD>"&Request.ServerVariables(ob)&"</TD></TR>"
next
Response.Write "</TABLE>"

26.
本机ip<%=request.servervariables("remote_addr")%>
服务器名<%=Request.ServerVariables("SERVER_NAME")%>
服务器IP<%=Request.ServerVariables("LOCAL_ADDR")%>
服务器端口<%=Request.ServerVariables("SERVER_PORT")%>
服务器时间<%=now%>
IIS版本<%=Request.ServerVariables"SERVER_SOFTWARE")%>
脚本超时时间<%=Server.ScriptTimeout%>
本文件路径<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
服务器CPU数量<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>
服务器解译引擎<%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %>
服务器操作系统<%=Request.ServerVariables("OS")%>

27.ENTER键可以让光标移到下一个输入框
<input οnkeydοwn="if(event.keyCode==13)event.keyCode=9">

28. 检测某个网站的链接速度:
把如下代码加入<body>区域中:
<script language=javascript>
tim=1
setInterval("tim++",100)
b=1

var autourl=new Array()
autourl[1]="www.njcatv.net"
autourl[2]="javacool.3322.net"
autourl[3]="www.sina.com.cn"
autourl[4]="www.nuaa.edu.cn"
autourl[5]="www.cctv.com"

function butt(){
document.write("<form name=autof>")
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO οnclick=window.open(this.form.url"+i+".value)><br/>")
document.write("<input type=submit value=刷新></form>")
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="链接超时"}
else
{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
b++
}
function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl[i]+"/"+Math.random()+" width=1 height=1 οnerrοr=auto('http://";+autourl[i]+"')>")}
run()</script>

29. 各种样式的光标
auto :标准光标
default :标准箭头
hand :手形光标
wait :等待光标
text :I形光标
vertical-text :水平I形光标
no-drop :不可拖动光标
not-allowed :无效光标
help :?帮助光标
all-scroll :三角方向标
move :移动标
crosshair :十字标
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize

图片显示控制:
<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" οnlοad="javascript:DrawImage(this);"
sw-resize

用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

'获取中文字符串拼音首字母串的函数
<%
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=# οnclick=javascript:history.go(-1)>返回</a>"
end if
%>
Set Objword = Nothing

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

取当前网页的地址全名,以便返回用
<%
Function GetUrl()
On Error Resume Next
Dim strTemp
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & Request.ServerVariables("SERVER_NAME")
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT")
strTemp = strTemp & Request.ServerVariables("URL")
If Trim(Request.QueryString) <> "" Then strTemp = strTemp & "?" & Trim(Request.QueryString)
GetUrl = strTemp
End Function
'Response.write GetUrl()
url1=GetUrl()
url1=Server.URLEncode(url1)

上传文件时,显示进度条程序

在需要引用进度条的也面上用
<script language="javascript" src="../ShowProcessBar.js"></script>

然后,
<input type="submit" value="开始上传" name="B1" IsShowProcessBar="True">
传参数 true

ShowProcessBar.js
—————————————————————————————————————————
AddProcessbar();
var bwidth=0;
var swidth = document.all.waiting.clientWidth;

function CheckIsProcessBar(obj)
{
if (obj.IsShowProcessBar=="True")
{
return false;
}
else
{
return true;
}
}

function CheckClick(e)
{
if (e == 1)
{
if (bwidth<swidth*0.98){
bwidth += (swidth - bwidth) * 0.025;
if (document.all)document.sbar.width = bwidth;
else document.rating.clip.width = bwidth;
setTimeout('CheckClick(1);',1000);

}
}
else
{
if(document.all)
{
if(document.all.waiting.style.visibility == 'visible')
{document.all.waiting.style.visibility = 'hidden';
bwidth = 1;}
whichIt = event.srcElement;

while (CheckIsProcessBar(whichIt))
{
whichIt = whichIt.parentElement;
if (whichIt == null)return true;
}


document.all.waiting.style.pixelTop = (document.body.offsetHeight - document.all.waiting.clientHeight) / 2 + document.body.scrollTop;
document.all.waiting.style.pixelLeft = (document.body.offsetWidth - document.all.waiting.clientWidth) / 2 + document.body.scrollLeft;
document.all.waiting.style.visibility = 'visible';
if(!bwidth)CheckClick(1);
bwidth = 1;

}

else
{

if(document.waiting.visibility == 'show')
{document.waiting.visibility = 'hide';
document.rating.visibility = 'hide';
bwidth = 1;}
if(e.target.href.toString() != '')
{
document.waiting.top = (window.innerHeight - document.waiting.clip.height) / 2 + self.pageYOffset;
document.waiting.left = (window.innerWidth - document.waiting.clip.width) / 2 + self.pageXOffset;
document.waiting.visibility = 'show';
document.rating.top = (window.innerHeight - document.waiting.clip.height) / 2 + self.pageYOffset+document.waiting.clip.height-10;
document.rating.left = (window.innerWidth - document.waiting.clip.width) / 2 + self.pageXOffset;
document.rating.visibility = 'show';
if(!bwidth)CheckClick(1);
bwidth = 1;
}
}
return true;
}
}

function AddProcessbar()
{

var Str=""
Str+= "<div id=waiting style=position:absolute;top:50px;left:100px;z-index:1;visibility:hidden >";
Str+= "<layer name=waiting visibility=visible zIndex=2 >"
Str+= "<table border=2 cellspacing=1 cellpadding=0 bordercolorlight=#FFFFFF bordercolordark=#C0C0C0 bgcolor=#E0E0E0>"
Str+= " <tr>"
Str+= " <td bgcolor=#E0E0E0 height=30px width=300px align=center>"
Str+= " <font color=black>数据正在处理中...</font>"
Str+= " </td>"
Str+= " </tr>"
Str+= " <tr>"
Str+= " <td bgcolor=#E0E0E0>"
Str+= " <img width=1 height=10 name=sbar style=background-color:#6699cc>"
Str+= " </td>"
Str+= " </tr>"
Str+= "</table> "
Str+= "</layer>"
Str+= "</div>"
document.write(Str)

if(document.all)document.onclick = CheckClick;

'功能: 过虑HTML字符
'输入:字符串
'输出:经格式化后的字符串
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", "&gt;")
fString = replace(fString, "<", "&lt;")

fString = Replace(fString, CHR(32)&CHR(32), "&nbsp;&nbsp;")
fString = Replace(fString, CHR(9), "&nbsp;")
fString = Replace(fString, CHR(34), "&quot;")
fString = Replace(fString, CHR(39), "&#39;")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")

HTMLEncode = fString
end if

'参数:系统(如:product,article),条件(如果是数值,则默认为categoryID的值),排序,
'每页显示记录数,模式(more:显示更多字样,page:显示翻页导航),
'翻页导航模式(number:显示数字,page:显示上一页,下一页),记录显示模版名(显示记录的过程名)
class List
dim p_system '系统表,如tblProduct,tblArticle
dim p_where '条件
dim p_orderBy '排序
dim p_recordCount '每页显示记录数
dim p_horizontal '每行显示记录数
dim p_mode '列表模式,参数:more(更多模式,显示更多字样),page(列表模式,显示翻页导航)
dim p_moreURL '更多模式时的URL
dim p_paginationMode '翻页导航模式,参数:number(数字导航,显示如:1,2,3,4),page(翻页导航,显示如:上一页,下一页)
dim p_models '列表模版过程
dim p_table '列表的table标签
dim p_page '页码
dim p_member '是否显示会员产品
dim p_groupWhere

Private Sub Class_Initialize
p_system=""
p_where=""
p_orderBy=" order by categoryID,orderBy,postdate"
p_recordCount=15
p_horizontal=4
p_mode=""
p_moreURL=""
p_paginationMode="page"
p_models=""
p_table="<table width=100% border=0 align=center cellpadding=0 cellspacing=0 bordercolor=#CCCCCC style='border-collapse: collapse'>"
p_page=1
p_member=false
p_groupWhere="groupID=0"
End Sub

Property Let system(value)
p_system=value
end property
Property Let where(value)
if isInt(value) then
p_where=" where categoryID="&value
else
p_where=" where ("&value&")"
end if
end property
Property Let orderBy(value)
p_orderBy=" order by "&value
end property
Property Let recordCount(value)
p_recordCount=value
end property
Property Let horizontal(value)
p_horizontal=value
end property
Property Let mode(value)
p_mode=value
end property
Property Let moreURL(value)
p_moreURL=value
end property
Property Let paginationMode(value)
p_paginationMode=value
end property
Property Let models(value)
p_models=value
end property
Property Let table(value)
p_table=value
end property
Property Let page(value)
if getNumeric(value)<1 then
p_page=1
else
p_page=int(value)
end if
end property
Property Let member(value)

p_member=value

if p_member then
authorizationID=getValue("tblMember","authorizationID","memberID="&session("memberID"))
if authorizationID="" or authorizationID=0 then
authorizationID=getValue("tblGroup","authorizationID","groupID="&session("groupID"))
end if
virtual=getValue("tblAuthorization","virtual","authorizationID="&authorizationID)
authArr=split(virtual,",")
for i=0 to ubound(authArr)
if i=0 then
p_groupWhere="groupID="&getValue("tblGroup","groupID","authorizationID="&authArr(i))
else
p_groupWhere=p_groupWhere&" or groupID="&getValue("tblGroup","groupID","authorizationID="&authArr(i))
end if
next
else
p_groupWhere="groupID=0"
end if
end property

'列表过程
public sub List()
dim rs
dim where

if p_where="" then
where=" where "&p_groupWhere&" and publish=1"
else
where=p_where&" and ("&p_groupWhere&") and publish=1"
end if



strSql="select * from "&p_system&where&p_orderBy
'response.write strSql
'response.end
set rs=getRecord(strSql)

if rs.eof then
response.write convertEncode(lgeNoRecord,gb,language)
exit sub
end if

rs.pageSize=p_recordCount

if rs.pagecount<p_page then p_page=rs.pagecount

rs.AbsolutePage=p_page

dim ii
response.write p_table
for i=1 to p_recordCount
if rs.eof then
exit for
end if
response.write "<tr>"
for ih=0 to p_horizontal
if ii=p_recordCount then
exit for
end if
if rs.eof then
response.write "<td width=" & 1/(p_horizontal+1)*100 & "% >&nbsp;</td>"
else
response.write "<td width=" & 1/(p_horizontal+1)*100 & "% >"
execute "call " & p_models
response.write "</td>"
rs.movenext
end if
ii=ii+1
next
response.write "</tr>"
next
response.write "</table>"

if p_mode="more" then
response.write "<div align=right>"&p_moreURL&"</div>"
end if
if p_mode="page" then
response.write "<table width=100% border=0 cellspacing=0 cellpadding=3><tr><td align=right>"
call pagination(p_page,rs.recordCount,rs.pageCount,p_paginationMode)
response.write "</td></tr></table>"
end if
end sub
end class

ASP操纵SerV-U开FTP
http://expert.csdn.net/Expert/topic/2322/2322539.xml?temp=1.874942E-02


连结其他数据库的方法(*.dbf,*.txt,excel,foxpro等) ----收藏
2002-10-30 18:41:05 浏览次数:145

'连结dbf文件
<%
' 建立Connection 对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Visual FoxPro Driver};"
SourceType = "SourceType=DBF;"
DBPath = "SourceDB=" & Server.MapPath( "Dbf" )

' 调用Open 方法连接数据库
conn.Open Driver & SourceType & DBPath

Set rs = Server.CreateObject("ADODB.Recordset")
' 打开数据源,参数二为Connection对象
rs.Open "Select * From sample", conn, 2, 2
%>
'连结foxpro文件
<%
' 建立Connection 对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Visual FoxPro Driver};"
SourceType = "SourceType=DBC;"
DBPath = "SourceDB=" & Server.MapPath( "Dbf/Sample.dbc" )

' 调用Open 方法连接数据库
conn.Open Driver & SourceType & DBPath

Set rs = Server.CreateObject("ADODB.Recordset")
' 打开数据源,参数二为Connection对象
rs.Open "Select * From sample", conn, 2, 2
%>

'连结excel文件
<%
' 建立Connection对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath( "Sample.xls" )

' 调用Open 方法连接数据库
conn.Open Driver & DBPath

Set rs = Server.CreateObject("ADODB.Recordset")
' 打开数据源,参数二为Connection对象
rs.Open "Select * From [成绩单$]", conn, 2, 2
%>

'连结txt文件
<%
' 建立Connection 对象
Set conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Text Driver (*.txt; *.csv)};"
DBPath = "DBQ=" & Server.MapPath( "Text" )

' 调用Open 方法连接数据库
conn.Open Driver & DBPath

Set rs = Server.CreateObject("ADODB.Recordset")
' 打开数据源,参数二为Connection对象
rs.Open "Select * From sample.txt", conn, 2, 2


%>
'-------------------------------列表过程结束-------------------------------------------------------------
end function
}

%>

end function
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值