/ Published in: ASP

A function and if statement to detect whether or not the browser is a mobile device.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<% Function Is_Mobile() Set Regex = New RegExp With Regex .Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm|ipad)" .IgnoreCase = True .Global = True End With Match = Regex.test(Request.ServerVariables("HTTP_USER_AGENT")) If Match then Is_Mobile = True Else Is_Mobile = False End If End Function %> //USAGE <%If Is_Mobile() then%> <h1>You are using a mobile device</h1> <%Else%> <h1>You are not using a mobile device</h1> <%End If%>
Comments
