ASP to get the Address bar URL in the top-level domain name function, not regular, very practical, personal debugging and easy to use.
In the production of a DLL component, because the DLL is not convenient to call the regular function, so, the production of a do not need to get the function with the domain name, contribute to everyone!
The following is the program code private Function durl (URL)
Dim domext, S1, S2, Re, matches, Arrdom, DD
Domext = "comnetorgcnlaccinfohkbizmemobinametvasiakrdeorg.cnco.krcom.cnnet.cngov.cn"
Arrdom = Split (Domext, "")
Durl = "": url = LCase (URL)
If url = "" Or Len (URL) = 0 Then Exit Function
url = replace (replace (URL, "http://", ""), "https://", "")
S1 = InStr (URL, ":")-1 ' Filter off port
If S1 < 0 Then S1 = InStr (URL, "/")-1 ' filter off/back characters
If s1 > 0 Then url = Left (URL, s1)
S2 = Split (URL, ".") (UBound (Split (URL, "."))
If InStr (domext, s2) = 0 Then
Durl = URL
Else
For dd = 0 to UBound (arrdom)
If InStr (URL, "." & Arrdom (dd)) > 0 Then
Durl = Replace (URL, "." & Arrdom (DD) & "", "")
If InStr (Durl, ".") = 0 Then
Durl = URL
Else
Durl = Split (Durl, ".") (UBound (Split (Durl, ".")) & "." & Arrdom (DD)
End If
End If
Next
End If
End Function