如何检测浏览器是否支持requestFullscreen
?
我在下面有这些代码来制作chrome、safari、firefox和opera(不完全工作)来制作全屏文档,但我想检测浏览器是否支持requestFullscreen
。我应该怎么办?
$('.button-fullscreen').click(function(){
var docElm = document.documentElement;
// W3C Proposal
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
}
// mozilla proposal
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
}
// Webkit (works in Safari and Chrome Canary)
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
return false;
});
$('.button-sound').click(function(){
// W3C Proposal
if (document.exitFullscreen) {
document.exitFullscreen();
}
// mozilla proposal
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
// Webkit (works in Safari and Chrome Canary)
else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
return false;
});