分享到微信的h5页面

css:<style>
            * {
                border: 0px;
                margin: 0px;
                padding: 0px;
                list-style: none;
                font-family: "微软雅黑";
                font-size: 14px;
            }
            body, html{width: 100%;
                height: 100%;
                background-color: #EFEFEF;
                }
            .clear {
                clear: both;
            }
            .con2 {
                width: 90%;
                height: 50px;
                margin: 0 auto;
                padding-top: 150px;
                text-align: center;
            }
            .con2 button {
                width: 120px;
                height: 30px;
                color: #FFFFFF;
                border-radius: 5px;
                background-color: #4694f9;
            }
        </style>

dom:

<body>
        <div class="con">
            <div class="con2">
                <button id="btnAddhuodong" class="btn_participation">我要参与</button>
            </div>
            
        </div>

        <!--如果是微信浏览器点击按钮显示遮罩-->
        <div id="divIPhone" style="background-color: Black; display: none; filter: Alpha(opacity=80);
        opacity: 0.8; position: absolute; top: 0; z-index: 999; width: 100%; 
        text-align: center; padding-top: 20px;">
 <img src="提示图">

//就是需要一张这样的图
        </div>
    </body>

javaScript:

<script type="text/javascript">
            //根据传入的参数查看传入的数据
            function GetQueryString(p) {
                var re = new RegExp("[&,?]" + p + "=([^\\&]*)", "i");
                var a = re.exec(document.location.search);
                if(a == null)
                    return "";
                return a[1];
            }

            /*是否是微信瀏覽器*/
            function isWeiXin() {
                var ua = window.navigator.userAgent.toLowerCase();
                if(ua.match(/MicroMessenger/i) == 'micromessenger') {
                    return true;
                } else {
                    return false;
                }
            }

            $(function() {
                var _height = document.body.scrollHeight;
                $("#divIPhone").css("height", _height);
                //        立即参与
                $("#btnAddhuodong").click(function() {
                    if(isWeiXin()) {
                        $("#divIPhone").show();
                    } else {
                       // myhkhtext:为Android、ios的内部设置标识
                        location.href = "myhkhtext://";  //打开APP  
                        setTimeout(function() {
                            location.href = "http://www.hkhsc.com/tops/appdownload.aspx";  //打开下载APP页面
                        }, 2000);
                        
                        return;
                    }
                })
            })
        </script>

猜你喜欢

转载自my.oschina.net/u/3474921/blog/1555298