Detect Mobile Safari
Many scripts on the web detect only Safari, or only Apple devices, but return false positives like desktop Safari or Mobile Chrome. Here's my take to detect only Mobile Safari - Save for the next time it drives you crazy with creative & annoying bugs:
/iP(ad|hone|od).+Version\/[\d\.]+.*Safari/i
As a Modernizr test:
Modernizr.addTest('mobilesafari', function() {
return /iP(ad|hone|od).+Version\/[\d\.]+.*Safari/i.test(navigator.userAgent);
});
Source for Safari-only part: urbz on StackOverflow
Written by Ronny Orbach
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mobile
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#