边缘到边缘导航问题

EDGE TO EDGE NAVIGATION ISSUE

我有一个应用程序需要在边缘打开一些应用程序。前任。按钮上有按钮 onclick 会有一个 link 应用程序,因此它只会在边缘打开。为此,我使用了这段代码 RedirectToCostAnalytics() { window.location.href = 'microsoft-edge:https://google.com/'; } 当我在 chrome 和 IE 中 运行 应用程序时它正在工作,但是当我在边缘 运行 应用程序并单击按钮时它给我 'ERROR:NAVIGATION' 消息。这是常见问题还是我做错了什么??

您使用的是哪个版本的 Edge?我已经在 Edge Legacy 和 Edge Chromium 上进行了测试,url 方案无法在任一 Edge 浏览器上打开,但我没有看到任何错误。

作为解决方法,您可以在打开 link 之前检查浏览器版本:

window.navigator.userAgent.indexOf("Edge") > -1  //check for Edge Legacy
window.navigator.userAgent.indexOf("Edg") > -1   //check for Edge Chromium

工作代码示例:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <input type="button" value="test" onclick="RedirectToCostAnalytics()"/>
    <script>
        function RedirectToCostAnalytics() {
            if ((window.navigator.userAgent.indexOf("Edge") > -1) || (window.navigator.userAgent.indexOf("Edg") > -1)) {
                window.location.href = 'https://google.com/';
            }
            else {
                window.location.href = 'microsoft-edge:https://google.com/';
            }
        }
    </script>
</body>
</html>