We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54cddc5 commit e1bcde5Copy full SHA for e1bcde5
README.md
@@ -52,3 +52,6 @@ study
52
53
### shake
54
* 仿微信摇一摇原型
55
+
56
+## modeCode
57
+* 值得收藏的代码片段
modcode/openApp.js
@@ -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