我正在尝试在屏幕更改上添加事件(完整/默认)。给定的函数在chrome中很好用,但在firefox中不起作用。
if (myid.addEventListener){
myid.addEventListener('webkitfullscreenchange' , changeScreen , false)
myid.addEventListener('mozfullscreenchange' , changeScreen , false)
myid.addEventListener('fullscreenchange' , changeScreen , false)
myid.addEventListener('MSwebkitfullscreenchange' , changeScreen , false)
}
else {
myid.attachEvent('fullscreenchange' , changeScreen)
}
function changeScreen(){
if (mydiv.id != 'oldid') {
mydiv.id = 'oldid'
}
else {
mydiv.id = 'newid'
}
}
我错了。请不要J查询。只有JavaScript。
答案 0 :(得分:1)
'mozfullscreenchange'是包含元素的文档事件(在这种情况下,我认为'myid'是元素)。
所以,我认为你可以修改你的代码:
if (myid.addEventListener){
myid.addEventListener('webkitfullscreenchange' , changeScreen , false)
document.addEventListener('mozfullscreenchange' , changeScreen , false)
myid.addEventListener('fullscreenchange' , changeScreen , false)
myid.addEventListener('MSwebkitfullscreenchange' , changeScreen , false)
}
您可以在此链接中找到有关'mozfullscreenchange'的更多信息(通知部分):https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API