Skip to content

Commit e1bcde5

Browse files
committed
add app check method
1 parent 54cddc5 commit e1bcde5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ study
5252

5353
### shake
5454
* 仿微信摇一摇原型
55+
56+
## modeCode
57+
* 值得收藏的代码片段

modcode/openApp.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//协议为:com.baidu.tieba:// ,微信的:weixin://
2+
//<meta name='apple-itunes-app' content='app-id=477927812'> 百度的appid
3+
document.getElementById('openApp').onclick = function(e){
4+
// 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为
5+
// 否则打开a标签的href链接
6+
var ifr = document.createElement('iframe');
7+
ifr.src = 'com.baidu.tieba://';
8+
ifr.style.display = 'none';
9+
document.body.appendChild(ifr);
10+
window.setTimeout(function(){
11+
document.body.removeChild(ifr);
12+
},3000)
13+
};

0 commit comments

Comments
 (0)