iPad version detection in JavaScript

前端 未结 9 780
耶瑟儿~
耶瑟儿~ 2020-12-06 11:12

Is it possible to check for the iPad version (1 or 2) in a web application? As the user agent looks identical (see http://www.webtrends.com/Support/KnowledgeBase/SolutionDet

9条回答
  •  春和景丽
    2020-12-06 11:49

    How about:

    // For use within normal web clients 
    var isiPad = navigator.userAgent.match(/iPad/i) != null;
    
    // For use within iPad developer UIWebView
    // Thanks to Andrew Hedges!
    var ua = navigator.userAgent;
    var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua);
    

    Also, check out this:

    http://davidwalsh.name/detect-ipad

提交回复
热议问题