When user clicks link with custom protocol (like myapp://superlink
)
I need either launch an app or allow user to download and run configuration app
There is this old tricks that it always never fails me.
The core functionality that you need is setTimeout
. I will tell you in detail:
setTimeout(function() {
window.location = "http://itunes.com/app/yourapplocation";
}, 200);
// once you do the custom-uri, it should properly execute the handler, otherwise, the settimeout that you set before will kick in
window.location = "myapp://superlink";
Now you mentioned that it maybe a link or links so I made this nice function just for your convenience:
HTML code
Click here
JS code
$("a[href*='myapp://']").click(function(e)
{
var el = $(this);
setTimeout(function() {
window.location = el.data("data-href-alt");
}, 200);
// once you do the custom-uri, it should properly execute the handler, otherwise, the settimeout that you set before will kick in
window.location = el.data("href");
e.preventDefault();
});
Hope this will help you :)