//判断设备横竖屏时的操作
function handleOrientationChange(mql){
if(mql.matches){
//此时设备是竖屏
}else{
//此时设备是横屏
}
}
var mql = window.matchMedia("(orientation:portrait)");
mql.addListener(handleOrientationChange);
handleOrientationChange(mql);
//移除监听事件
//mql.removeListener(handleOrientationChange);
function handleOrientationChange(mql){
if(mql.matches){
//此时设备是竖屏
}else{
//此时设备是横屏
}
}
var mql = window.matchMedia("(orientation:portrait)");
mql.addListener(handleOrientationChange);
handleOrientationChange(mql);
//移除监听事件
//mql.removeListener(handleOrientationChange);