如何在App浏览器中添加URL重定向?

时间:2019-03-26 04:25:31

标签: javascript html redirect

我已经完成以下代码来检测网站中的FB应用内浏览器:-我知道如果检测到FB-In App浏览器时如何添加重定向window.location.href = "http://www.example123website.com";

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>App Link</title>
<script language="JavaScript" type="text/JavaScript">
   function isFacebookApp() {
    var ua = navigator.userAgent || navigator.vendor || window.opera;
     window.location.href = "http://www.example123website.com";

    return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1);

}

    </script>


</head>
<body>


</body>
</html>

1 个答案:

答案 0 :(得分:0)

代码如下:

如果isFacebookApp成功:

function isFacebookApp() {
            var ua = navigator.userAgent || navigator.vendor || window.opera;
            var s  = (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1) ;
             if(s> -1  &&  s!=false)
            {
                window.location.href = "http://www.example123website.com";
            }
        }