Hello guys, today I want to show you how you can open up multiple links using a single click.
The method behind this trick is to put multiple links on single hyperlink.
This is the normal link would look like.
<a href=”YOUR-LINK” alt=”_blank”>YOUR ANCHOR TEXT</a>
Let say you want to open two links when a visitor clicks a link, what you have to do is modify above code and add this code
just before first closing bracket “>” symbol.
And the new code would be like this
<a href=”YOUR-LINK” onclick=”window.open("YOUR-2nd-LINK");” >YOUR ANCHOR TEXT</a>
But I use another approach and use below code instead to open two links. Using above approach, I can’t figure out how to open the first link in new tab as I already added alt=”blank” to the code. But the below approach does work.
<a target=”_blank” onclick=”window.open("YOUR-LINK"); window.open("YOUR-2nd-LINK");” >YOUR ANCHOR TEXT</a>
Here a demo, Click to open two links in new tabs.
To open three links it would be like this
<a target=”_blank” onclick=”window.open("YOUR-LINK"); window.open("YOUR-2nd-LINK"); window.open("YOUR-3nd-LINK");” >YOUR ANCHOR TEXT</a>
And if you want add more link, press spacebar once before ” >YOUR ANCHOR TEXT</a> and insert window.open("YOUR-NEW-LINK");.
Hope this will be helpful.
And before I end this post, you should consider what for actually you apply this trick and what your readers would think of this method. I personally would feel weird if a site that I visit opens up multiple tabs when I click on a link.
Update: I changed the code a bit because it did not work anymore. Previously there was href=”#” in the code, however, if I add it now, my browser (Firefox) will open three tabs for the link with two sites which the third is this post you are reading. I think it is due to browser compatibility with the code and I don’t think it is because of blogging platform that I use. Previously I used Blogger and Now WordPress. Without the href, the mouse cursor won’t change into hand when hovered on the hyperlink but it does work, at least for me, for now.Like di Facebook dan Subscribe di YouTube: