在您的网站中进行本机浏览器检测后是否可以在外部浏览器中打开它

问题描述 投票:0回答:1

我受到谷歌地图的启发, 当它检测到本机浏览器时,建议在应用程序中使用它 检测过程很简单,但我不确定,

问题是:

在 ANDROID 设备上 我如何强制我的网站用户退出本机浏览器并在默认(外部)浏览器中打开它

谷歌浏览器:

googlechrome://域名

这是简单的检测片段

function isInFacebookApp() {
      return /FBAV/i.test(navigator.userAgent);
    }

if (isInFacebookApp()) {
  // do somthing window.open("https://my-website.com");
} else {
  console.log("native browser not detected");
}`
android google-chrome browser progressive-web-apps native
1个回答
0
投票

经过一点测试后,我发现这个并且工作得很好

就我而言 android 和默认浏览器 google-chrome

// 对于 Android 使用“意图:”链接

  if (/Android/i.test(navigator.userAgent)) {
    window.location.href = 'intent:https://your-website.com#Intent;end';
  } else {
    // For other platforms, use window.open with a fallback
    window.open('https://your-site.com');
  }
© www.soinside.com 2019 - 2024. All rights reserved.