You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.8 KiB
47 lines
1.8 KiB
// 横屏
|
|
var detectOrient = function() {
|
|
var width = document.documentElement.clientWidth,
|
|
height = document.documentElement.clientHeight,
|
|
wrapper = document.getElementById("wrap"),
|
|
style = "";
|
|
if(width >= height) { // 竖屏
|
|
style += "width:100%";
|
|
style += "height:100%;";
|
|
style += "-webkit-transform: rotate(0); transform: rotate(0);";
|
|
style += "-webkit-transform-origin: 0 0;";
|
|
style += "transform-origin: 0 0;";
|
|
} else { // 横屏
|
|
style += "width:" + height + "px;"; // 注意旋转后的宽高切换
|
|
style += "height:" + width + "px;";
|
|
style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);";
|
|
// 注意旋转中点的处理
|
|
style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
|
|
style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
|
|
}
|
|
wrapper.style.cssText = style;
|
|
}
|
|
window.onresize = detectOrient;
|
|
detectOrient();
|
|
|
|
//$(document).ready(function(){
|
|
var browser = {
|
|
versions: function() {
|
|
var u = navigator.userAgent,
|
|
app = navigator.appVersion;
|
|
return { //移动终端浏览器版本信息
|
|
trident: u.indexOf('Trident') > -1, //IE内核
|
|
presto: u.indexOf('Presto') > -1, //opera内核
|
|
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
|
|
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
|
|
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
|
|
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
|
|
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
|
|
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
|
|
iPad: u.indexOf('iPad') > -1, //是否iPad
|
|
webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
|
|
};
|
|
}(),
|
|
language: (navigator.browserLanguage || navigator.language).toLowerCase()
|
|
}
|
|
|
|
|