I want to open my site only in iPhone and iPod with Safari browser. For any other browser like Chrome, Dolphin, etc, It shouldn\'t open.
But currently I am getting the s
The browsers do this very deliberately to prevent people from doing what you're trying to do. Their developers feel that since they're using the same web engine (WebKit, blink or gecko) as the others that they'll lkely render pages optimized for similar browsers just fine (which is likely true).
So most likely there is no way to tell.
The other answer isn't strictly correct. On iOS, Apple block any competing browsers from actually including their own rendering engine; all must use the standard webview.
So all of those 3rd party browsers (with functionality such as syncing favourites, etc.) are simply wrappers around the Safari powered webview that's actually rendering the page, hence them all having Safari's user agent string.
Solves for mercury, opera, chrome n firefox but not dolphin
(
(/(iPad|iPhone|iPod)/gi).test(userAgent) &&
!(/CriOS/).test(userAgent) &&
!(/FxiOS/).test(userAgent) &&
!(/OPiOS/).test(userAgent) &&
!(/mercury/).test(userAgent)
)