function openApp(e) {
var u = window.navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if (isAndroid) {
android();
}
if (isiOS) {
ios();
}
}
function android() {
var _clickTime = new Date().getTime();
window.location.href = '';
var _count = 0, intHandle;
intHandle = setInterval(function () {
_count++;
var elsTime = new Date().getTime() - _clickTime;
if (_count >= 100 || elsTime > 3000) {
clearInterval(intHandle);
if (document.hidden || document.webkitHidden) {
window.close();
} else {
window.location.href = ''
}
}
}, 20);
}
function ios() {
var _clickTime = +(new Date());
var ifr = document.createElement("iframe");
ifr.style.display = "none";
document.body.appendChild(ifr);
var _count = 0, intHandle;
intHandle = setInterval(function () {
_count++;
var elsTime = +(new Date()) - _clickTime;
if (_count >= 100 || elsTime > 3000) {
clearInterval(intHandle);
document.body.removeChild(ifr);
if (document.hidden || document.webkitHidden) {
window.close();
} else {
}
}
}, 20);
}
$('#openbtn').click(function () {
openApp()
})