【问题标题】:Redirect from facebook browser to Safari Apple从 Facebook 浏览器重定向到 Safari Apple
【发布时间】:2023-01-25 03:00:02
【问题描述】:

此脚本将用户从 facebook 浏览器重定向到 android 设备上的 google chrome,我需要它在以下设备上做同样的事情:

  • Android (google chrome) 和 iphone(safari) 上的 Instagram 浏览器
  • iPhone 上的 Facebook 浏览器(重定向到 Safari)

这是现在正在运行的代码:

<script>
    function isFacebookApp() {
        var ua = navigator.userAgent || navigator.vendor || window.opera;
        return (ua.indexOf("FBAV") > -1) || (ua.indexOf("FBAN") > -1);
    }
if (isFacebookApp()) {
    var currentLink = location.href;
    if (currentLink.indexOf('https') > -1) {
        var currentLink = currentLink.replace('https://', '');
        currentLink = currentLink.replace('www.', '');
        var chromeLink = "intent://" + currentLink + "#Intent;scheme=https;package=com.android.chrome;end";
        window.location.href = chromeLink;
    }
    if (currentLink.indexOf('http') > -1) {
        var currentLink = currentLink.replace('http://', '');
        currentLink = currentLink.replace('www.', '');
        var chromeLink = "intent://" + currentLink + "#Intent;scheme=http;package=com.android.chrome;end";
        window.location.href = chromeLink;
    }
} 
</script> 

谢谢

【问题讨论】:

    标签: javascript redirect user-agent


    【解决方案1】:

    你设法找出如何做到这一点?太感谢了!

    【讨论】:

    猜你喜欢
    • 2014-07-26
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    • 2022-12-11
    • 2020-03-13
    • 2018-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多