<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <script> var downurl= ‘http://27.195.157.198:8000/jiayouzhan/Public/app.apk‘;//需要下载的app路径 function is_weixin() { var ua = navigator.userAgent.toLowerCase(); if (ua.match(/MicroMessenger/i) == "micromessenger") { return true; } } 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 id=\"wx-img\" src=\"img/lx1.jpg\" 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: absolute; left:0; top:0; background: rgba(0,0,0,0.8); filter:alpha(opacity=80); width: 100%; height:960px; z-index: 1000;} #weixin-tip p{text-align: center; margin-top: 10%; padding:0 5%;}#wx-img{ width: 95%; position: absolute;left: 15px;top: 0px;}"; if(isWeixin){ loadHtml(); loadStyleText(cssText);//如果是微信就显示图片 } else{ location.href=downurl;//如果不是微信就显示下载 } </script> </body> </html>