Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a link open multiple pages when clicked

I have two (or more) links. For example: http://google.com and http://yahoo.com.

How can I make them both open when I click on a single link?

For example, a link entitled "click here" which, when clicked, will open two different blank windows.

like image 761
Benjamin Avatar asked Aug 15 '11 12:08

Benjamin


People also ask

How do I make a link open every page?

Simply hold down the Ctrl key while clicking normally on a link and it should open in the background.

How do I open multiple hyperlinks at once?

When the Microsoft Visual Basic window opens, press the F5 key and click OK. This will open all the selected hyperlinks in your default browser.

Is there a way to open multiple links at once in Chrome?

To do this, you'll need to hold down the right mouse button, then draw a box around the links you want opened. A tiny number appears on the bottom right corner of the selection box to indicate how many links will be opened. As soon as you release the mouse button, all selected links will open at the same time.


1 Answers

HTML:

<a href="#" class="yourlink">Click Here</a> 

JS:

$('a.yourlink').click(function(e) {     e.preventDefault();     window.open('http://yoururl1.com');     window.open('http://yoururl2.com'); }); 

window.open also can take additional parameters. See them here: http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

You should also know that window.open is sometimes blocked by popup blockers and/or ad-filters.

Addition from Paul below: This approach also places a dependency on JavaScript being enabled. Not typically a good idea, but sometimes necessary.

like image 184
Adam Terlson Avatar answered Sep 30 '22 23:09

Adam Terlson