我有一个来自第三方开发者的 JavaScript 文件。它有一个链接,用目标替换当前页面。我想在新标签页中打开此页面。
这是我目前所拥有的:
if (command == 'lightbox') {
location.href="https://support.wwf.org.uk/earth_hour/index.php?type=individual";
}
谁能帮帮我?
最佳答案
window.open(
'https://support.wwf.org.uk/earth_hour/index.php?type=individual',
'_blank' // <- This is what makes it open in a new window.
);
关于JavaScript:location.href 在新窗口/标签中打开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5141910/