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.
Simply hold down the Ctrl key while clicking normally on a link and it should open in the background.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With