如何仅检测是否是iOS设备并重定向?

Ali*_*Ali 4 iphone flash redirect detect

我目前正在使用它来检测访问者是否安装了闪存,如果没有立即我假设他们是iPhone用户但是现在它似乎并不总是像我希望的那样工作,因为有时他们被重定向到我的网站的Flash版本,有时安装了Flash的人也重定向到我的网站的iPhone版本

<!DOCTYPE html>
<html>
<head>    
     <script src="http://www.featureblend.com/flash_detect_1-0-4/flash_detect.js" type="text/javascript" charset="utf-8"></script> 

<script type="text/javascript"> 
    if(!FlashDetect.installed){
        window.location = "?flash=false";       
    }else{
        window.location = "?flash=true";
    }
    </script>
</head>
Run Code Online (Sandbox Code Playgroud)

问题是我如何检测它们是否像iPhone/iPad/iPod/AppleTV那样并将它们重定向到flash = false URL,如果它们不属于上述类型,将重定向到flash = true?

我试图找到但实际上找不到我想要的确切内容

谢谢你们和Merry X'Mas给大家.

And*_*ega 8

有很多关于如何实现这一目标的教程.你可以从这里开始:http: //www.hand-interactive.com/resources/detect-mobile-javascript.htm

简而言之,您只需在用户代理字符串中查找字符串"iphone","ipod","ipad"等...,其代码类似于:

var uagent = navigator.userAgent.toLowerCase();

if (uagent.search("iphone") > -1 ||
    uagent.search("ipod") > -1 ||
    uagent.search("ipad") > -1 ||
    uagent.search("appletv") > -1) {
   window.location = "?flash=false";       
} else {
   window.location = "?flash=true";
}
Run Code Online (Sandbox Code Playgroud)

祝你圣诞快乐:)