User Agent for Safari browser on iOS 7

后端 未结 3 1747
心在旅途
心在旅途 2021-02-05 14:01

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

相关标签:
3条回答
  • 2021-02-05 14:13

    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.

    0 讨论(0)
  • 2021-02-05 14:26

    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.

    0 讨论(0)
  • 2021-02-05 14:29

    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)
    )
    
    0 讨论(0)
提交回复
热议问题