I am trying to figure out how to launch an app upon loading a website. The idea is, a user clicks a link in an email or text, and it brings them to a webpage, witch will redirect them to either the app if they have it installed, or the webpage if they dont have the app, or are using a computer. I have this script here
launchApp = function () {
window.location = "<app launch url>";
setTimeout(launchWebpage, 25);
}
launchWebpage = function () {
window.location = "<Webpage Url>";
}
$( window ).on( "load",launchApp);
This loads the web page, but does not launch the app. If I get rid of the bottom window on load section, and instead call my launchApp function directly from a button, like
<button id="test" onclick="launchApp()">Button</button>
everything works. It launches the app if installed, and if not, the webpage loads. How can I get this to work automatically instead of having to press the button?