gpt4 book ai didi

javascript - 通过 Javascript 在 Windows Metro 应用程序中打开 url

转载 作者:行者123 更新时间:2023-11-28 02:45:25 25 4
gpt4 key购买 nike

通常,当我使用<a href="_URL_"></a>时在我的 Metro 应用程序中,URL 在默认 Web 浏览器中打开。我不想使用 anchor 来执行此操作,我想通过 Javascript 和异步执行相同的行为。但我不知道如何使用默认浏览器打开该网址。

这是我的代码:

var $aTag = $("<a/>").click(function (event) {
showYesNoDialog(
"Do you approve?",
"The link will be opened in another window. Do you approve?",
"Yes", // Text of yes button
"No", // Text of no button
function () { // Behavior of yes button
// I tried this but nothing happened.
window.location.href = _URL_; // Should open in chrome or default web browser
},
function () { // Behavior of no button
// do nothing
}
);
});

我还尝试过的是:

$("<a href='" + _URL_ + "'></a>").click();

但这也不起作用。

最佳答案

最后,我在谷歌搜索中找到了答案。 Open a URL in a new tab (and not a new window) using JavaScript

我使用此代码打开了 Metro 应用程序的网址,它在我的情况下有效:

window.open(_URL_, '_blank');
window.focus();

关于javascript - 通过 Javascript 在 Windows Metro 应用程序中打开 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11974883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com