将网站从 facebook 网络浏览器重定向到手机的默认浏览器

Posted

技术标签:

【中文标题】将网站从 facebook 网络浏览器重定向到手机的默认浏览器【英文标题】:Redirect website from facebook web browser to mobile's default browser 【发布时间】:2020-03-13 16:08:35 【问题描述】:

如何将任何网站从 Facebook 网络浏览器重定向到移动默认浏览器。我想使用 javascript 执行此操作。 这个我试过了

window.open('', '_system');

但是没有用。 有什么建议吗?

【问题讨论】:

【参考方案1】:

我正在使用这个脚本,它运行良好,但它重定向到谷歌浏览器。

<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> 

【讨论】:

以上是关于将网站从 facebook 网络浏览器重定向到手机的默认浏览器的主要内容,如果未能解决你的问题,请参考以下文章