Simple way to identify iOS user agent in a jQuery if/then statement?

前端 未结 6 2043
心在旅途
心在旅途 2021-02-01 03:16

Exactly like it sounds..

Is there some magical and easy way to say:

    if (user agent is iOS) {
        if (browserRatio >=1.5) {
            $contai         


        
6条回答
  •  一个人的身影
    2021-02-01 03:35

    To make sure this string doesn't get matched: Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 925) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537 just change your code to

    if (navigator.userAgent.match(/(\(iPod|\(iPhone|\(iPad)/)) {
        if (browserRatio >=1.5) {
            $container.css('min-height', '360px');
        } else {
            $container.css('min-height', '555px');
        }
    }
    

提交回复
热议问题