微信打开下载App提示

微信打开下载App提示
 1 <style type="text/css">
 2     * {
 3         margin: 0;
 4         padding: 0;
 5     }
 6 
 7     img {
 8         max-width: 100%;
 9         height: auto;
10     }
11 
12     .test {
13         height: 600px;
14         max-width: 600px;
15         font-size: 40px;
16     }
17 </style>
CSS

 

微信打开下载App提示
 1 <script type="text/javascript">
 2     function is_weixin() {
 3         var ua = navigator.userAgent.toLowerCase();
 4         if (ua.match(/MicroMessenger/i) == "micromessenger") {
 5             return true;
 6         } else {
 7             return false;
 8         }
 9     }
10     var isWeixin = is_weixin();
11     var winHeight = typeof window.innerHeight != undefined ? window.innerHeight : document.documentElement.clientHeight;
12     console.log(winHeight);
13     function loadHtml() {
14         var div = document.createElement(div);
15         div.id = weixin-tip;
16         div.innerHTML = <p><img src="/images/live_weixin.png" alt="微信打开"/></p>;
17         document.body.appendChild(div);
18     }
19     function loadStyleText(cssText) {
20         var style = document.createElement(style);
21         style.rel = stylesheet;
22         style.type = text/css;
23         try {
24             style.appendChild(document.createTextNode(cssText));
25         } catch (e) {
26             style.styleSheet.cssText = cssText; //ie9以下
27         }
28         var head = document.getElementsByTagName("head")[0]; //head标签之间加上style样式
29         head.appendChild(style);
30     }
31     var cssText = "#weixin-tip{position: fixed; left:0; top:0; background: rgba(0,0,0,0.8); filter:alpha(opacity=80); width: 100%; height:100%; z-index: 100;} #weixin-tip p{text-align: center; margin-top: 10%; padding:0 5%;}";
32     if (isWeixin) {
33         loadHtml();
34         loadStyleText(cssText);
35     } else {
36         var os = function () {
37             var ua = navigator.userAgent,
38                 isQB = /(?:MQQBrowser|QQ)/.test(ua),
39                 isWindowsPhone = /(?:Windows Phone)/.test(ua),
40                 isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
41                 isAndroid = /(?:Android)/.test(ua),
42                 isFireFox = /(?:Firefox)/.test(ua),
43                 isChrome = /(?:Chrome|CriOS)/.test(ua),
44                 isIpad = /(?:iPad|PlayBook)/.test(ua),
45                 isTablet = /(?:iPad|PlayBook)/.test(ua) || (isFireFox && /(?:Tablet)/.test(ua)),
46                 isSafari = /(?:Safari)/.test(ua),
47                 isPhone = /(?:iPhone)/.test(ua) && !isTablet,
48                 isOpen = /(?:Opera Mini)/.test(ua),
49                 isUC = /(?:UCWEB|UCBrowser)/.test(ua),
50                 isPc = !isPhone && !isAndroid && !isSymbian;
51             return {
52                 isQB: isQB,
53                 isTablet: isTablet,
54                 isPhone: isPhone,
55                 isAndroid: isAndroid,
56                 isPc: isPc,
57                 isOpen: isOpen,
58                 isUC: isUC,
59                 isIpad: isIpad
60             };
61         }();
62         var downURL = os.isPhone ? https://itunes.apple.com/cn/app/ai-mei-yi-jia/id1029744813?mt=8 : http://www.mm-jia.com/download/AiMeiYiJia.apk;
63         window.location = downURL;
64     }
65 </script>
Js

 

微信打开下载App提示
1 <body>
2     <div class="test">
3     </div>
4 </body>
Body

微信打开下载App提示

微信打开下载App提示

上一篇:超简单--仿微信朋友圈展开显示更多文字功能


下一篇:小程序硬件配网的两种方式