Detect android webview

前端 未结 3 1458
别那么骄傲
别那么骄傲 2021-01-21 01:45

I have an html-javascript page, and I need to detect whenever it open on web view (Like inside facebook webview, twitter webview, etc.), and if it a webview - displ

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-21 02:27

    The info others provided in this thread gave me what I needed to solve this problem in my case. For others, here is the resulting JS regex which represents the detection described in the accepted answer:

    /(Version\/\d+.*\/\d+.0.0.0 Mobile|; ?wv|(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari))/i.test(navigator.userAgent)
    

    The regex includes cases for old Android, new Android, iOS versions.

提交回复
热议问题