Posted By

nshakin on 05/17/13


Tagged

browser detection mobile ASP


Versions (?)

Detect Mobile Browser Using ASP


 / Published in: ASP
 

A function and if statement to detect whether or not the browser is a mobile device.

  1. <%
  2. Function Is_Mobile()
  3. Set Regex = New RegExp
  4. With Regex
  5. .Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm|ipad)"
  6. .IgnoreCase = True
  7. .Global = True
  8. End With
  9. Match = Regex.test(Request.ServerVariables("HTTP_USER_AGENT"))
  10. If Match then
  11. Is_Mobile = True
  12. Else
  13. Is_Mobile = False
  14. End If
  15. End Function
  16. %>
  17.  
  18. //USAGE
  19.  
  20. <%If Is_Mobile() then%>
  21. <h1>You are using a mobile device</h1>
  22. <%Else%>
  23. <h1>You are not using a mobile device</h1>
  24. <%End If%>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: lakkie on October 3, 2013

Even shorter:

0 End Function %>

You need to login to post a comment.