当前位置:首页 > ASP教程 > 应用技巧

强制刷新和判断文件地址

复制代码 代码如下:

强制刷新网页
<% 
  '强制性刷新随机验证码
  '让随机验证码每次按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
%>

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!