html根據手機螢幕大小做自适應
彈框寬高自适應,核心代碼
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i) ? true : false;
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i) ? true : false;
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i) ? true : false;
},
any: function () {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
}
};
var clientWidth = document.body.clientWidth;//浏覽器視圖寬度
var clientHeight = document.body.clientHeight;//浏覽器視圖高度
function textAdvertising() {
var width = "630px";
var height = "700px";
if (isMobile.any()) {
width = clientWidth-50+"px";
height = clientHeight-100+"px";
}
......