25

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?

2
  • 3
    What's the reasoning for not using JS? :-) Commented Apr 6, 2011 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. Commented Apr 6, 2011 at 13:27

5 Answers 5

45

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Can you say more about the "unless" part? :)
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).
This functionality will work on emails? I think no because all mail servers either is change or removed the second url.
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?
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

1 Comment

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"
4

it is not possible to do using only html

Comments

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.

1 Comment

But that's also JS
-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>

1 Comment

That'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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.