First, for Android and iOS we have to do a different operation, the following is to determine the system's JS code
Alert (IsMobile (1)); 1 indicates that android,0 iOS
function IsMobile (test) {
var u = navigator.useragent, app = Navigator.appversion;
if (/applewebkit.*mobile/i.test (navigator.useragent) | | (/midp| symbianos| nokia| Samsung| Lg| nec| tcl| alcatel| bird| dbtel| dopod| philips| haier| lenovo| mot-| nokia| sonyericsson| sie-| amoi| Zte/.test (navigator.useragent))) {
if (Window.location.href.indexOf ("? mobile") <0) {
try{
if (/iphone|mac|ipod|ipad/i.test (navigator.useragent)) {
Return ' 0 ';
}else{
Return ' 1 ';
}
}catch (e) {}
}
}else if (u.indexof (' IPad ') >-1) {
Return ' 0 ';
}else{
Return ' 1 ';
}
}
Second, JS call app End Function, the following is JS code
if (IsMobile (1) ==1) {
Android.settypeactivity (ID,TYPE,HREF);
}else{
Jstoios (ID,TYPE,HREF);
}
Settypeactivity is a function defined on the Android side, Jstoios is a function defined on the iOS side, and is a parameter that is passed by the JS side in parentheses.
Third, as for the JS end of how to obtain the app end of the data, just in the JS end to provide the app End Function name, in the Notification app end call can
There is also a way to pass the data to another page without using the app, which is through the URL
In this page, the data is spliced behind the IP
On another page, get the parameters after the URL by using the following method
function Getrequest () {
var url = location.search; Get the "?" in the URL String after the character
var therequest = new Object ();
if (Url.indexof ("?")!=-1) {
var str = URL.SUBSTR (1);
STRs = Str.split ("&");
for (var i = 0; i < strs.length i + +) {
Therequest[strs[i].split ("=") [0]]=decodeuricomponent (Strs[i].split ("=") [1]);
}
}
return therequest;
}
Get URL parameters
var Request = new Object ();
Request = Getrequest ();
var name;
name = request[' name '];
Just started to do with the app interactive HTML5, a bit overwhelmed, in fact, this description on the internet has a lot of information, I am now specialized in front of the point of view to sum up.
Many native apps now embed more or less HTML5 pages, so it's important to know how JS interacts with native apps, and how to interact better to optimize app interaction, which requires constant practice.