本文将Asp编程中的一些常用的函数进行了归纳和总结,这些函数在程序中都是经常用到的,例如打开一个新的窗体,关闭窗体,文中进行注释等等。欢迎有兴趣的朋友一起来完善。(1)打开一个窗体<script language="JavaScript">
<!--
function openWindow(topic) {
window.open("xxxx.asp",topic,"width=600,height=380,scrollbars=yes");
}
//-->
</script>(2)弹出命令,并指向一个新的页面response.write"<SCRIPT language=JavaScript>alert('用户"&uname&"成功退出登录,正在返回首页!');"
response.write"this.location.href='./';</SCRIPT>" %>response.write"<SCRIPT language=JavaScript>alert('用户"&firm_username&"资料修改成功!');"
response.write"this.location.href='index.asp';</SCRIPT>" %>(3)关闭窗口response.write"<SCRIPT language=JavaScript>alert('新闻添加成功!');"
response.write"javascript:window.close();</SCRIPT>"%>
<a href="javascript:window.close()"><font size="3">[关闭窗口]</font></a>
[<a href="javascript:window.close()">关闭窗口</a>](4)在项目中加入注释<!--
/*****************************************************************
* Project Name:
* Version: 1.0.1
*****************************************************************
* Copyright (c) 2003 *********. All Rights Reserved.
*
*****************************************************************
* Maintain Logs Time Author Comments
*----------------------------------------------------------------
* 1 2004-02-09 21:43 ****** for Ver1.0.1
*----------------------------------------------------------------
*****************************************************************
*/
-->(5)取得表单提交的所有数据
<% For Each x In Request.Form %>
Request.Form( <%= x %> ) = <%= Request.Form(x) %> <BR>
<% Next %>
或
<%
For i = 1 To Request.Form("inputname").Count
Response.Write Request.Form("inputname")(i) & "<BR>"
Next
%>
(6)限制某个段的IP地址function IP2Num(sip)
dim str1,str2,str3,str4
dim num
IP2Num=0
if isnumeric(left(sip,2)) then
str1=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str2=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str3=left(sip,instr(sip,".")-1)
str4=mid(sip,instr(sip,".")+1)
num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
IP2Num = num
end if
end functionfunction Num2IP(nip)
iip1 = int(nip/256/256/256)
iip2 = int((nip-iip1*256*256*256)/256/256)
iip3 = int((nip-iip1*256*256*256-iip2*256*256)/256)
iip4 = int((nip-iip1*256*256*256-iip2*256*256-iip3*256) mod 256)
iip0 = iip1 &"."& iip2 & "." &iip3 &"."& iip4
Num2IP = iip0
end functionuserIPnum = IP2Num(Request.ServerVariables("REMOTE_ADDR"))if userIPnum > IP2Num("192.168.0.0") and userIPnum < IP2Num("192.168.0.255") then
response.write ("<center>您的IP被禁止</center>")
response.end
end if(7)获取真实的IP地址function GetIp()
dim realip,proxy
realip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
proxy = Request.ServerVariables("REMOTE_ADDR")
if realip = "" then
GetIp = proxy
else
GetIp = realip
end if
end function
共同学习,写下你的评论
评论加载中...
作者其他优质文章