【问题标题】:Redirection of existing tab and opening a new tab重定向现有选项卡并打开新选项卡
【发布时间】:2022-01-15 11:16:12
【问题描述】:

我想复制当您单击本网站上的“优惠券代码”按钮时发生的情况 - https://couponfollow.com/。我看到发生的情况是,我所在的选项卡已被重定向到(商店的)新 URL,而新选项卡会以弹出模式打开。我可以做一个或另一个,但我不确定如何完成这两个动作。您对此有什么建议吗?

【问题讨论】:

  • 使用window.open()打开新标签页,分配给window.location重定向当前标签页。

标签: javascript php redirect modal-dialog


【解决方案1】:

document.addEventListener('click', function(){
  window.location = 'https://google.com'; // current tab
  window.open('https://google.de', '_blank').focus(); // new tab
});

【讨论】:

  • 谢谢!会试试这个!欣赏!
猜你喜欢
  • 1970-01-01
  • 2012-01-15
  • 2017-12-05
  • 1970-01-01
  • 2012-04-25
  • 2022-12-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多