0

Here is my code

Html Code

I am trying to open app if installed otherwise it will redirect me to play store. Its working when i click on link but i need to redirect it automatically

 <a id="link_id" href="app://details?id=agd.solutions.myapplication"fallbackhref="market://details?id=agd.solutions.myapplication">Click to download</a>

Jquery Code

I have tried everything but its not working

     jQuery('#link_id').click(); 
     $("#link_id").trigger("click"); 
     $('a').get(0).click(); 
     $('a')[0].click(); 
     $('#link_id')[0].click();

Tried all the above option but not working

Jordan
  • 39
  • 1
  • 13
  • According to the [documentation](https://learn.jquery.com/events/triggering-event-handlers/): _"The `.trigger()` (which is basicly what triggers `.click()`) function cannot be used to mimic native browser events, such as clicking on a file input box or an anchor tag. This is because, there is no event handler attached using jQuery's event system that corresponds to these events."_. You may want to read [this Q/A](https://stackoverflow.com/q/6068266/5768908) to solve the issue. – icecub Jan 04 '20 at 08:22
  • Does this answer your question? [jQuery: how to trigger anchor link's click event](https://stackoverflow.com/questions/6068266/jquery-how-to-trigger-anchor-links-click-event) – icecub Jan 04 '20 at 08:24
  • first: `var link = $("#link_id").attr("href");` then, in PHP: `location.href = link;` – Reza sh Jan 04 '20 at 10:35

2 Answers2

0

Try this:

$('#link_id')[0].click();

thingEvery
  • 3,368
  • 1
  • 19
  • 25
0

You can try something link this.

window.open($("#link_id").attr("href"))

Working fiddle here

Shuaib Khan
  • 119
  • 4