码迷,mamicode.com
首页 > 微信 > 详细

微信在浏览器打开前的提示页面Android与IOS判断

时间:2017-08-17 17:15:11      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:filter   idt   提示页面   node   打开   cas   color   try   技术   

直接在网上扒一个页面,分分钟搞定!  先看一下效果

技术分享

这是用微信开发工具打开的样式,直接上完整代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>忆游APP下载</title>
</head>
<body>
    <style type="text/css">
    *{margin:0; padding:0;}
    img{max-width: 100%; height: auto;}
    .test{height: 600px; max-width: 600px; font-size: 40px;}
    </style>
    
    <script type="text/javascript">
        var img = android.png;
        function is_weixin() {
            var ua = navigator.userAgent.toLowerCase();
            if(ua.indexOf(iphone) > -1){
                    img = iphone.png;
            }else{
                    img = android.png;
            }
            if (ua.match(/MicroMessenger/i) == "micromessenger") {
                return true;
            } else {
                return false;
            }
        }
        var isWeixin = is_weixin();
        var winHeight = typeof window.innerHeight != undefined ? window.innerHeight : document.documentElement.clientHeight;

        function loadHtml(){
            var div = document.createElement(div);
            div.id = weixin-tip;
            div.innerHTML = <p><img src="+ img +" alt="微信打开"/></p>;
            document.body.appendChild(div);
        }
        
        function loadStyleText(cssText) {
            var style = document.createElement(style);
            style.rel = stylesheet;
            style.type = text/css;
            try {
                style.appendChild(document.createTextNode(cssText));
            } catch (e) {
                style.styleSheet.cssText = cssText; //ie9以下
            }
            var head=document.getElementsByTagName("head")[0]; //head标签之间加上style样式
            head.appendChild(style); 
        }
        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%;}";
        if(isWeixin){
            loadHtml();
            loadStyleText(cssText);
        }else{
                window.location.href="http://static.youliaoar.com/operation/yiyou/aryiyou1.1.0.apk";
        }
    </script>
</body>
</html>

 

微信在浏览器打开前的提示页面Android与IOS判断

标签:filter   idt   提示页面   node   打开   cas   color   try   技术   

原文地址:http://www.cnblogs.com/duanyue/p/7382602.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!