Click a button to jump directly to the app if it is installed, or jump to the download link if it is not.

  javascript

Many h5 pages have buttons to open/download immediately, such as Netease News
http://3g.163.com/ntes/special/00340EPA/wapSpecialModule.html?sid=S1465956142051&spst=2&spss=newsapp&spsf=wx&spsw=1

For example, Toutiao
http://toutiao.com/i6298416478102225409/?tt_from=weixin&utm_campaign=client_share&from=singlemessage&app=news_article&utm_source=weixin&isappinstalled=1&iid=4639652216&utm_medium=toutiao_ios&wxshare_count=2&pbid=19604438942

There is such a button when opening the mobile terminal. After clicking, if the app is installed in the mobile phone, it will be opened directly. If it is not installed, it will jump to download. May I ask how this logic is implemented? As far as I know, js cannot judge whether app is installed on the mobile phone.

Ask experienced great gods to dispel doubts!


Thank you for your positive answer. The pit encountered now is that in safri of iphone, clicking will bring up a pop-up prompt asking me whether to open the app or telling me that the link is invalid, because the reason for this prompt leads to problems with the logic of setTimeout, so I wonder if you have any way to stop safri’s pop-up.

I didn’t expect so many people to pay attention to this problem.
Yesterday, a classmate also asked me in a private letter whether this problem had been solved.

It can’t be regarded as a perfect solution, but there are also some research experiences, so I wrote my summary of this problem in the following article, inside. Interested students are welcome to have a look. It’s all hard work! Please praise me! ! !

In the browser, arouse native app || jump to the application mall to download