分享到微信的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>