ASP functions are a necessary part of the asp web programming implementation function, but do you know about ASP functions? In fact, we only need to master a few commonly used ASP functions, so let’s take a look at the introduction of commonly used ASP functions now.
========= Get the URL with port, it is recommended to use =======================
Function Get_ScriptNameUrl()
If request.servervariables("SERVER_PORT")="80" Then
Get_ScriptNameUrl="http://" & request.servervariables("server_name")&lcase(request.servervariables("script_name"))
Else
Get_ScriptNameUrl="http://" & request.servervariables("server_name")&":"&request.servervariables("SERVER_PORT")&lcase(request.servervariables("script_name"))
End If
End Function
The above is an introduction to commonly used ASP functions. After reading it, do you understand ASP functions?
'===================== Function to highlight the words found in the string with regular expressions=================================
Function BoldWord(strContent,word)
If word="" Then
BoldWord = strContent
Exit Function
End IF
dim objRegExp
Set objRegExp=new RegExp
objRegExp.IgnoreCase =true
objRegExp.Global=True
objRegExp.Pattern="(" & word & ")"
strContent=objRegExp.Replace(strContent,"<font color=""#FF0000""><b>$1</b></font>" )
Set objRegExp=Nothing
BoldWord=strContent
End Function
'======================= Get the user's current IP address====================
Function GetIP()
uIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If uIP = "" Then uIP = Request.ServerVariables("REMOTE_ADDR")
GetIp = uIP
End Function
'==================== Get the current program script path=====================
Function GetScriptName()
ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME"))'Get the current address
If (Request.QueryString <> "") Then
ScriptAddress = ScriptAddress & "?" & Server.HTMLEncode(Request.QueryString)' Get the address with parameter
End If
If Len(ScriptAddress)>250 Then ScriptAddress = Left(SciptAddress,250)&"..." 'Perform path intercepting, with a maximum of 250 characters
GetScriptName = ScriptAddress
End Function
'================ Return Url with parameters, used when sorting multiple keywords =====================
' RemoveList parameter: The parameters that need to be removed from the Url can be multiple, please separate them with commas in the middle.
Function KeepUrlStr(RemoveList)
ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME"))&"?"' Get the current address and add the "?" symbol
M_ItemUrl = ""
For Each M_item In Request.QueryString
If InStr(RemoveList,M_Item)=0 Then
M_ItemUrl = M_ItemUrl & M_Item &"="& Server.URLEncode(Request.QueryString(""&M_Item&"")) & "&"
End If
Next
KeepUrlStr = ScriptAddress & M_ItemUrl
End Function