<分区>
我正在使用 action=abc.pl
提交表单,abc.pl 包含用于打开新选项卡并在同一页面上加载不同 URL 的代码。这是我正在做的代码(在 abc.pl 中)
window.open('$thisPage')
window.location.href='$nextPage';
但是 window.open
在新窗口中打开,而不是在新标签页中打开。
<分区>
我正在使用 action=abc.pl
提交表单,abc.pl 包含用于打开新选项卡并在同一页面上加载不同 URL 的代码。这是我正在做的代码(在 abc.pl 中)
window.open('$thisPage')
window.location.href='$nextPage';
但是 window.open
在新窗口中打开,而不是在新标签页中打开。
最佳答案
根据之前关于 StackOverflow 的问题:Open a URL in a new tab (and not a new window) using JavaScript
function open_in_new_tab(url )
{
var win=window.open(url, '_blank');
win.focus();
}
或
$('a').click(function() {
$(this).attr('target', '_blank');
});
关于javascript - 在新标签页中打开一个页面并在旧窗口中加载不同的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15481557/