Loading JS script for only iOS devices?

后端 未结 3 795
野性不改
野性不改 2020-12-14 04:18

I have a jQuery script I\'m using on a site to allow fixed position background images on iPhone/iPad/iPod. However it seems to be clashing with another script I am using on

相关标签:
3条回答
  • 2020-12-14 04:44

    You can use Detect Mobile Browser (it has a library for javascript).

    0 讨论(0)
  • 2020-12-14 05:04

    you can also try this

    if (navigator.userAgent.match(/like Mac OS X/i)) {
                    alert('Hi, you\'re browsing from an iOS device.');
    }
    
    0 讨论(0)
  • 2020-12-14 05:05

    You can use the Mobile Safari user agent string to detect mobile safari server-side, see: How do I detect Mobile Safari server side using PHP?


    You can also do this in JavaScript:

    if(navigator.userAgent.match(/(iPhone|iPod|iPad)/i))
    

    See iPhone & iPod Detection Using JavaScript for more information.

    0 讨论(0)
提交回复
热议问题