简体   繁体   English

如何一次打开两个网页? 这适用于所有设备,iPhone除外

[英]How to open two web pages at once? This is working on all devices with the exception of iPhones

The goal is to click on one link and for that link to open a new web page. 目的是单击一个链接,然后对该链接打开一个新的网页。 Then I would like to redirect the original web page to a new page. 然后,我想将原始网页重定向到新页面。 To put it simply, I want one link to open two different web pages on a single click! 简而言之,我希望一个链接单击即可打开两个不同的网页!

The Issue: I have managed to make this work using. 问题:我设法使这项工作得以使用。 "location.href" “location.href”

This manages to work on every device with the exception of iPhones. 这样可以在除iPhone之外的所有设备上运行。 There are a few different ways to write “location.href,” for example “window.location.href,” I have followed every single trick from Stack Overflow and I am still running into issues. 有几种不同的写“ location.href”的方法,例如“ window.location.href”。我遵循了Stack Overflow的每一个技巧,但仍然遇到问题。 I have tried using “window.open” but this results in a popup blocker being initiated on click. 我尝试使用“ window.open”,但这会导致在单击时启动弹出窗口阻止程序。 I then thought it may help to set a delay using JS and then calling the redirect, this failed. 然后,我认为使用JS设置延迟然后调用重定向可能会有所帮助,但失败了。 If you can provide any insight on making this work on iPhones, it would be greatly appreciated, thank you. 如果您能提供有关在iPhone上实现此功能的任何见解,将不胜感激,谢谢。

<div class="button-offer-box">
    <a href="example.com" onclick="location.href='example_site.com';"  target="_blank">open two pages</a>
</div>

I would like to have the link open a new page and have the existing page redirected, again this needs to work on iPhones, any help is greatly appreciated. 我想让该链接打开一个新页面并重定向现有页面,再次需要在iPhone上使用,非常感谢您的帮助。 Thank you in advance for reading this, I truly appreciate it. 预先感谢您阅读本文,我真的很感激。

我建议您使用javascript完成所有操作:


<a onclick="location.href='http://example_site.com';window.open('http://example_site2.com', '_blank')">open two pages</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM