強制刷新網頁
<% '強制性刷新隨機驗證碼 '讓隨機驗證碼每次按IE的後退按鈕時,返回登錄頁面的隨即碼都自動刷新, Response.expires=-1 Response.AddHeader"pragma","no-cache" Response.AddHeader"cache-control","no-store" %>
判斷文件地址是否有效
<% Response.Write("") On Error Resume Next Dim thisurl,thistext thisurl=Request("thisurl") '定義文件地址(非Html格式文檔)! if thisurl="" then Response.Write("請先輸入文件地址!") 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("建立連接失敗,文件不存在或網絡有問題!;錯誤原因:"&Err.Description&"!") 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,"")<>0 then Response.Write(""& ii &" × ") Else Response.Write(""& ii &" √ ") End if Next if Err then Err.Clear Response.Write("碰到意外!;錯誤原因:"&Err.Description&"!") Response.End End if %>
以上就是ASP強制刷新網頁和判斷文件地址實例代碼,希望對大家的學習有所幫助。