WEBAPP JS Open App

Source: Internet
Author: User

Product Requirements: Share out links such as to the Friends Circle, Weibo H5 page, add a button open app for opening and launching your company's app (if the current phone has installed its own company's app)

Nonsense less say directly on the code:

<input type= "button" value= "Open" onclick= "Openapp () from app, S" ><script language= "JavaScript" >function Openapp () {var schemeurl = ' app has protocols such as:  Apps custom URL schemes ';    if (Navigator.userAgent.match (/(Iphone|ipod|ipad);? /i)) {       var loaddatetime = new Date ();       Window.settimeout (function () {           var timeoutdatetime = new Date ();   if (Timeoutdatetime-loaddatetime <) {           window.location = ' link to jump when the app is not installed ';    } else {       alert (' cannot open '); 
   }         },25);        window.location = Schemeurl;
} else if (Navigator.userAgent.match (/android/i)) { var state = null; try {state = window.open (schemeurl, ' _blank '); } catch (e) {} if (state) { alert (' cannot open '); Window.close (); } else { window.location = ' link to jump when app is not installed '; }
</script>

  

What is the apps custom URL schemes ?
is actually a protocol URL that you agree with the app, and your iOS colleague or Android colleague sets a URL Scheme when writing a program.

For example, set: URL Scheme:app
The application can then be called by other programs via URLString = app://.

You can also pass parameters, such as: app://reaction/?uid=1
Principle: Within 500ms, this machine has the application can parse this protocol and open the program, call the application, if the native no application can resolve the protocol or 500MS does not open the program, then execute settimeout inside the function, is to jump to the page you want to jump.

WEBAPP JS Open App

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.