Mayank Tripathi Mayank Tripathi - 3 months ago 14
iOS Question

Detect if the user is navigating through the safari mobile browser on iphone

I am trying to detect if the user is navigating my website from safari browser on the iphone using jquery / javascript.

I am able to detect the IOS Environment using the user agent string

/iphone/i.test(navigator.userAgent.toLowerCase())


But this detects the Apple Webkit Environment i.e. it is same for all the browsers on the device. Can anyone suggest any different approach.

Answer

UPDATED:


Try this, for detecting Safari browser in an iPhone:

var isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);

It identifies Safari 3.0+ and distinguishes it from Chrome.

JsFiddle