<!-- 全屏的使用方法 -->
function fullScreen( elem ){
if ( elem.requestFullscreen ) {
elem.requestFullscreen();
} else if ( elem.webkitRequestFullScreen ) {
if ( window.navigator.userAgent.toUpperCase().indexOf( 'CHROME' ) >= 0 ) {
elem.webkitRequestFullScreen( Element.ALLOW_KEYBOARD_INPUT );
} else {
elem.webkitRequestFullScreen();
}
} else if ( elem.mozRequestFullScreen ) {
elem.mozRequestFullScreen();
}
};
<!-- 退出全屏的使用方法 -->
function exitFullSreen(){
if ( document.exitFullscreen ) {
document.exitFullscreen();
} else if ( document.webkitCancelFullScreen ) {
document.webkitCancelFullScreen();
} else if ( document.mozCancelFullScreen ) {
document.mozCancelFullScreen();
}
};
fullScreen(参数是需要全屏的id,必须用原生的js取到值);
exitFullSreen();退出的时候直接调用,不需要传入参数