31 December 2013

Open multiple link from single HTML link tag

Trick: You can open multiple links by single clicking the <a> tag (defines an anchor) using javascript code inside HTML. It is very simple. just include onclick() function and write inline javascript in its attribute.

Check this HTML code:

HTML Code:
<a href="http://www.google.com/" target="_blank" onclick="window.open(&quot;http://www.yahoo.com/&quot;);
This anchor opens three links in a single click </a>

Output of the Code:

This anchor opens three links in a single click

Note: (To work this trick) the code should be in the same line without any line break ...

onclick( )  : It is a function which runs when the link is clicked

window.open() : It is a function which opens another window with the given url

target : opens the link in blank/new window

To know more about it, Read :

(If you found this article useful then share with your friends.)

No comments: