asp/js函數收藏

來源:互聯網
上載者:User
asp/js函數收藏'*******************************************************************
'檢測是否是手機瀏覽
'*******************************************************************
<%
if instr(request.ServerVariables("HTTP_USER_AGENT"),"Mozilla")=0 then
 response.redirect "/wap" '如果用戶端為手機訪問,則進入/wap目錄
else
 response.redirect "http://wap.fz0132.com" '如果用戶端不是手機訪問,則進入指定地址
end if
%> '*******************************************************************
'取得IP地址
'*******************************************************************
Function Userip()
 Dim GetClientIP
 '如果用戶端用了Proxy 伺服器,則應該用ServerVariables("HTTP_X_FORWARDED_FOR")方法
 GetClientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
 If GetClientIP = "" or isnull(GetClientIP) or isempty(GetClientIP) Then
 '如果用戶端沒用代理,應該用Request.ServerVariables("REMOTE_ADDR")方法
 GetClientIP = Request.ServerVariables("REMOTE_ADDR")
 end if
 Userip = GetClientIP
End function
 '*******************************************************************
' 彈出對話方塊
'*******************************************************************
Sub alert(message)
 message = replace(message,"'","\'")
 Response.Write ("<script>alert('" & message & "')</script>")
End Sub'*******************************************************************
' 返回上一頁,一般用在判斷資訊提交是否完全之後
'*******************************************************************
Sub GoBack()
 Response.write ("<script>history.go(-1)</script>")
End Sub'*******************************************************************
' 重新導向另外的串連
'*******************************************************************
Sub Go(url)
 Response.write ("<script>location.href('" & url & "')</script>")
End Sub'*******************************************************************
' 指定秒數重新導向另外的串連
'*******************************************************************
sub GoPage(url,s)
 s=s*1000
 Response.Write "<SCRIPT LANGUAGE=JavaScript>"
 Response.Write "window.setTimeout("&chr(34)&"window.navigate('"&url&"')"&chr(34)&","&s&")"
 Response.Write "</script>"
end sub'*******************************************************************
' 判斷數字是否整形
'*******************************************************************
function isInteger(para)
on error resume next
dim str
dim l,i
if isNUll(para) then
isInteger=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isInteger=false
exit function
end if
l=len(str)
for i=1 to l
if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
isInteger=false
exit function
end if
next
isInteger=true
if err.number<>0 then err.clear
end function'*******************************************************************
' 獲得副檔名
'*******************************************************************
function GetExtend(filename)
dim tmp
if filename<>"" then
tmp=mid(filename,instrrev(filename,".")+1,len(filename)-instrrev(filename,"."))
tmp=LCase(tmp)
if instr(1,tmp,"asp")>0 or instr(1,tmp,"php")>0 or instr(1,tmp,"php3")>0 or instr(1,tmp,"aspx")>0 then
getextend="txt"
else
getextend=tmp
end if
else
getextend=""
end if
end function' *----------------------------------------------------------------------------
' * 函數:CheckIn
' * 描述:檢測參數是否有SQL危險字元
' * 參數:str要檢測的資料
' * 返回:FALSE:安全 TRUE:不安全
' * 作者:
' * 日期:
' *----------------------------------------------------------------------------
function CheckIn(str)
if instr(1,str,chr(39))>0 or instr(1,str,chr(34))>0 or instr(1,str,chr(59))>0 then
CheckIn=true
else
CheckIn=false
end if
end function' *----------------------------------------------------------------------------
' * 函數:HTMLEncode
' * 描述:過濾HTML代碼
' * 參數:--
' * 返回:--
' * 作者:
' * 日期:
' *----------------------------------------------------------------------------
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", "&gt;")
fString = replace(fString, "<", "&lt;")

fString = Replace(fString, CHR(32), "&nbsp;")
fString = Replace(fString, CHR(9), "&nbsp;")
fString = Replace(fString, CHR(34), "&quot;")
fString = Replace(fString, CHR(39), "&#39;")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")

HTMLEncode = fString
end if
end function '*----------------------------------------------------------------------------
' * 函數:HTMLcode
' * 描述:過濾表單字元
' * 參數:--
' * 返回:--
' * 作者:
' * 日期:
' *----------------------------------------------------------------------------
function HTMLcode(fString)
if not isnull(fString) then
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(34), "")
fString = Replace(fString, CHR(10), "<BR>")
HTMLcode = fString
end if
end function

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.