使用target_blank在点击时打开一个新标签 - 我可以自动在原始标签页中加载新页面吗?

时间:2022-10-07 08:35:25

I'm running an offer and when someone clicks through my first page I'd like them to be sent to another offer page in a new tab - pretty easy with target_blank.

我正在运行一项优惠,当有人点击我的第一页时,我希望将它们发送到新标签页中的另一个优惠页面 - 使用target_blank非常简单。

However, while the user is sent to the new tab, I'd like the original tab to load to another page - is this possible?

但是,当用户被发送到新选项卡时,我希望将原始选项卡加载到另一个页面 - 这可能吗?

Or, if not - would it be possible to open 2 different tabs simultaneously when the user clicks through my first page? Or, a new window and a new tab?

或者,如果没有 - 当用户点击我的第一页时,是否可以同时打开2个不同的标签?或者,一个新窗口和一个新选项卡?

I'd like to do this the first way I mentioned, but if that's not possible really any other way of opening two tabs/windows when the user clicks through the link on my first page would be great.

我想以我提到的第一种方式执行此操作,但是如果用户点击我的第一页上的链接时打开两个选项卡/窗口的任何其他方式都不可能,那就太棒了。

Thanks!

2 个解决方案

#1


1  

You could use an event listener for when the link is clicked and change the current windows location. An example with jQuery would be

您可以在单击链接时使用事件侦听器并更改当前窗口位置。 jQuery的一个例子就是

$('a').on('click', function () {
    window.location.href = "http://google.com";
});

Or native javascript

或原生javascript

document.getElementsByTagName('a')[0].addEventListener('click', function() {
    window.location.href = "http://google.com";
});

#2


0  

For the second part of the question. Use JS to open multiple pages with one click

对于问题的第二部分。使用JS只需单击即可打开多个页面

<a href="#" onclick="window.open('http://www.google.com'); window.open('http://www.bing.com');">One Click</a>

#1


1  

You could use an event listener for when the link is clicked and change the current windows location. An example with jQuery would be

您可以在单击链接时使用事件侦听器并更改当前窗口位置。 jQuery的一个例子就是

$('a').on('click', function () {
    window.location.href = "http://google.com";
});

Or native javascript

或原生javascript

document.getElementsByTagName('a')[0].addEventListener('click', function() {
    window.location.href = "http://google.com";
});

#2


0  

For the second part of the question. Use JS to open multiple pages with one click

对于问题的第二部分。使用JS只需单击即可打开多个页面

<a href="#" onclick="window.open('http://www.google.com'); window.open('http://www.bing.com');">One Click</a>