标签设置竖屏:
<meta name="x5-orientation" content="portrait">
css设置样式:
@media screen and (orientation: portrait) {
/*竖屏 css*/
}
@media screen and (orientation: landscape) {
/*横屏 css*/
}
<!-- 竖屏 -->
<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css"/>
<!-- 竖屏 -->
<link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css"/>
js监听:
window.addEventListener("onorientationchange"in window ? "orientationchange": "resize", function() {
if (window.orientation === 180 ||window.orientation=== 0){
console.log('竖屏状态!');
};
if (window.orientation === 90 ||window.orientation=== -90){
console.log('横屏状态!');
}
}, false);
移动端与PC端判断:
function browserRedirect() {
var sUserAgent = navigator.userAgent.toLowerCase();
if(/ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(sUserAgent)) {
//跳转手机端wap
window.location.href="http://www.xxx.com/wap";
}else{
//跳转pc
window.location.href="http://www.xxx.com";
}
}
browserRedirect();

3276

被折叠的 条评论
为什么被折叠?



