当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP实用技巧:强制刷新和判断文件地址

ASP
ASP系列讲座(十)ASP 内建对象
ASP系列讲座(十一)ActiveX 组件
ASP系列讲座(十二)向浏览器发送内容
ASP系列讲座(十三)向浏览器传送脚本
ASP系列讲座(十四)包含文件
ASP系列讲座(十五)使用 HTML 表格
ASP系列讲座(十六)访问数据库
ASP系列讲座(十七)调试 ASP 脚本
ASP系列讲座(十八)管理应用程序
ASP系列讲座(十九)管理会话
ASP系列讲座(二十)维护 ASP 应用程序的安全
ASP系列讲座(二十一)创建事务性脚本
ASP系列讲座(二十二)使用国际站点
ASP系列讲座(二十三)编写跨平台应用程序
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (一)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (二)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (三)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (四)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (五)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (六)

ASP实用技巧:强制刷新和判断文件地址


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 240 ::
收藏到网摘: n/a

   强制刷新网页

<%
  ’强制性刷新随机验证码
  ’让随机验证码每次按IE的后退按钮时,返回登录页面的随即码都自动刷新,
  Response.expires=-1
  Response.AddHeader"pragma","no-cache"
  Response.AddHeader"cache-control","no-store"
%>

  判断文件地址是否有效

<%
  ’原创作者:小艺 QQ:52093 时间:2005.6.30
  Response.Write("<head><style><!--span{ font-size: 9pt }--></style></head>")
  On Error Resume Next
  Dim thisurl,thistext
  thisurl=Request("thisurl") ’定义文件地址(非Html格式文档)!
  if thisurl="" then
   Response.Write("<span>请先输入文件地址!</span>")
   Response.End
  End if
  Function objxmlhttp(xmlurl)
   On Error Resume Next
   Set objxml = CreateObject("Microsoft.XMLHTTP")
   objxml.Open "get",xmlurl,false
   objxml.setrequestheader "content-type","application/x-www-form-urlencoded"
   objxml.send
   objxmlhttp = objxml.responsebody
   if Err then
    Err.Clear
    Response.Write("<span>建立连接失败,文件不存在或网络有问题!;错误原因:"&Err.Description&"!</span>")
    Response.End
   End if
  End Function

  Function bytes2BSTR(vIn)
   strReturn = ""
   For i = 1 To LenB(vIn)
    ThisCharCode = AscB(MidB(vIn,i,1))
    If ThisCharCode < &H80 Then
     strReturn = strReturn & Chr(ThisCharCode)
    Else
     NextCharCode = AscB(MidB(vIn,i+1,1))
     strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
     i = i + 1
    End If
   Next
   bytes2BSTR = strReturn
  End Function

  thisurl2=Split(thisurl,",")
  For Each ii In thisurl2
   thistext=bytes2BSTR(objxmlhttp(ii))
   if InStr(thistext,"<html>")<>0 then
    Response.Write("<span>"& ii &" <b>×</b></span><br>")
   Else
    Response.Write("<span>"& ii &" <b>√</b></span><br>")
   End if
  Next

  if Err then
   Err.Clear
   Response.Write("<span>碰到意外!;错误原因:"&Err.Description&"!</span>")
   Response.End
  End if
%>