JavaScript:location.href在新窗口/标签页中打开? [英] JavaScript: location.href to open in new window/tab?
本文介绍了JavaScript:location.href在新窗口/标签页中打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有来自第三方开发者的JavaScript文件。它有一个链接,用目标替换当前页面。我希望在新标签页中打开此页面。
I have a JavaScript file from a third party developer. It has a has link which replaces the current page with the target. I want to have this page opened in a new tab.
这是我到目前为止所做的:
This is what I have so far:
if (command == 'lightbox') {
location.href="https://support.wwf.org.uk/earth_hour/index.php?type=individual";
}
任何人都可以帮助我吗?
Can anyone help me out?
推荐答案
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在新窗口/标签页中打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文