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

时间:2008-5-31    作者:Deri    分类: 分享


   <p>  强制刷新网页</p><p>  <code><%<br /> ’强制性刷新随机验证码<br /> ’让随机验证码每次按IE的后退按钮时,返回登录页面的随即码都自动刷新,<br /> Response.expires=-1<br /> Response.AddHeader"pragma","no-cache"<br /> Response.AddHeader"cache-control","no-store"<br />%></code></p><p>  判断文件地址是否有效</p><p>  <code><%<br /> ’原创作者:小艺 QQ:52093 时间:2005.6.30<br /> Response.Write("<head></head>")<br /> On Error Resume Next<br /> Dim thisurl,thistext<br /> thisurl=Request("thisurl") ’定义文件地址(非Html格式文档)!<br /> if thisurl="" then<br />  Response.Write("请先输入文件地址!")<br />  Response.End<br /> End if<br /> Function objxmlhttp(xmlurl)<br />  On Error Resume Next<br />  Set objxml = CreateObject("Microsoft.XMLHTTP")<br />  objxml.Open "get",xmlurl,false<br />  objxml.setrequestheader "content-type","application/x-www-form-urlencoded"<br />  objxml.send<br />  objxmlhttp = objxml.responsebody<br />  if Err then<br />   Err.Clear<br />   Response.Write("建立连接失败,文件不存在或网络有问题!;错误原因:"&Err.Description&"!")<br />   Response.End<br />  End if<br /> End Function<br /> Function bytes2BSTR(vIn)<br />  strReturn = ""<br />  For i = 1 To LenB(vIn)<br />   ThisCharCode = AscB(MidB(vIn,i,1))<br />   If ThisCharCode < &H80 Then<br />    strReturn = strReturn & Chr(ThisCharCode)<br />   Else<br />    NextCharCode = AscB(MidB(vIn,i+1,1))<br />    strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))<br />    i = i + 1<br />   End If<br />  Next<br />  bytes2BSTR = strReturn<br /> End Function<br /> thisurl2=Split(thisurl,",")<br /> For Each ii In thisurl2<br />  thistext=bytes2BSTR(objxmlhttp(ii))<br />  if InStr(thistext,"<html>")<>0 then<br />   Response.Write(""& ii &" <b>×</b><br />")<br />  Else<br />   Response.Write(""& ii &" <b>√</b><br />")<br />  End if<br /> Next<br /> if Err then<br />  Err.Clear<br />  Response.Write("碰到意外!;错误原因:"&Err.Description&"!")<br />  Response.End<br /> End if<br />%></code></p>