I have some text in a link. When I click on it I must open 2 pages. No problem here... but the trick is that I am not allowed to use JavaScript. Is this possible only with HTML?
Asked
Active
Viewed 1.4e+01k times
25
-
3What's the reasoning for not using JS? :-) – Karol J. Piczak Apr 06 '11 at 13:19
-
If it's a no because "just don't use it", then the goal cannot be fulfilled. If there's some more compelling reason, maybe some workaround could be possible. – Karol J. Piczak Apr 06 '11 at 13:27
5 Answers
43
Without JavaScript, it's not possible to open two pages by clicking one link unless both pages are framed on the one page that opens from clicking the link. With JS it's trivial:
<p><a href="#" onclick="window.open('http://google.com');
window.open('http://yahoo.com');">Click to open Google and Yahoo</a></p>
Do note that this will be blocked by popup blockers built into web browsers but you are usually notified of this.

Marcel
- 27,922
- 9
- 70
- 85
-
2
-
i need a same thing but instead of (And) ,check whether i have the app i want to contact or not ,then choose to contact based on what app i have(skype Or telegram). – moh89 Oct 22 '17 at 11:57
-
This functionality will work on emails? I think no because all mail servers either is change or removed the second url. – Naveen Dec 14 '17 at 12:07
-
Can one achieve the same thing but open both pages in the same window/tab? The `frameset` solution does not work for html5 anymore; anything comparable available? – Cleb Apr 19 '18 at 08:02
12
<a href="http://www.omsaicreche.blogspot.com" onclick="location.href='http://www.omsaivatikanoida.blogspot.com';" target="_blank">Open Two Links With One Click</a>
I tried the above codes. I could not get success in old page. Than I created a new page in blogger and types following codes... I was successful

ByteHamster
- 4,884
- 9
- 38
- 53

Dharmesh
- 131
- 1
- 2
-
Note that if you want to open a different schema, e.g. `mailto:`, meaning your link goes to a new page and also sends some email, you need to put the `mailto:` URL in the `location.href=` and change `target="_blank"` to `target="_self"` – dgnuff Aug 06 '18 at 06:26
1
If you have the authority to edit the pages to be opened, you can href to 'A' page and in the A page you can put link to B page in onpageload attribute of body tag.

takirala
- 1,891
- 2
- 16
- 36
-10
it is working perfectly;
<p><a href="#"onclick="window.open('http://google.com');window.open('http://yahoo.com');">Click to open Google and Yahoo</a></p>

sifr_dot_in
- 3,153
- 2
- 33
- 42

vaibhav
- 1
-
6That's not only HTML. The onclick attribute has JavaScript in it, which is executed on the click. Although it's not a separate JavaScript file, it's still JavaScript. Also, there are other answers which show this same approach already. – RedYeti Sep 27 '17 at 14:56