<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>手机端APK下载界面</title>
<link rel="icon" href="image/favicon.ico">
</head>
<body>
<style type="text/css">
.layout-main {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-image: url('image/bg.png');
}
.layout-content {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 90%;
height: 90%;
max-height: 470;
margin: auto;
overflow: hidden;
background-image: url('image/bg1.png');
background-repeat: no-repeat;
background-position: center left;
background-size: 100% 100%;
}
.layout-download {
position: absolute;
left: 23%;
right: 23%;
bottom: 8%;
overflow: hidden;
height: 40px;
background-image: url('image/down.png');
background-repeat: no-repeat;
background-position: center left;
background-size: 100% 100%;
cursor: pointer;
}
</style>
<div class="layout-main">
<div class="layout-content">
<div class="layout-download" onclick="downloadFile()"></div>
</div>
</div>
<script type="text/javascript">
function downloadFile() {
var isWeixin = is_weixin();
if (isWeixin) {
loadHtml();
loadStyleText(cssText);
}
else {
const url = "www.baidu.com/111.apk";
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.click();
}
}
function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger" || ua.match(/AlipayClient/i) == "alipayclient") {
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="image/live_weixin.png" 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;padding-right: 20px;} #weixin-tip img{width: 100%;}";
// if(isWeixin){
// loadHtml();
// loadStyleText(cssText);
// }
</script>
</body>
</html>