LoganPHP LoganPHP - 1 year ago 59
Javascript Question

How to fire hyper link through jquery trigger?

I want to fire hyper link through javascript. It link must be open in new tab.

We can use window.open('url') but we know browser blocks popup. So i need alternate solution for it.

I have tried with trigger() but it doesn't work.

My HTML code is :

<input id="btn" type="button" value="Click to fire">
<a id="link" href="http://www.google.com" target="_blank">Link</a>

My script is :


Besides i used click(), it doesn't work too.

Code is :


Can you any one help me?

Answer Source

Here is your solution - http://jsfiddle.net/svTWu/1/

Here is the code

<input id="btn" type="button" value="Click to fire">
<a class="thelink" href="http://www.google.com" target="_blank">Link</a>

$(".thelink").click(function () {

$("#btn").click(function () {

Here you can read all information about trigger - http://api.jquery.com/trigger/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download