Re: fullscreen mode 全屏

这个API很有用。

这里顺便发一下我的fullscreen的兼容脚本(window.fullScreen属性和fullscreenchange事件)。

if (!('fullScreen' in window)) Object.defineProperty(window, 'fullScreen', {
get: function() {
return (screen.width == window.outerWidth && screen.height ==
window.outerHeight)
}
})
var _fullScreen = window.fullScreen
if (!('onfullscreenchange' in window)) window.addEventListener('resize',
function() {
var f = window.fullScreen
if (f != _fullScreen) {
_fullScreen = f
fireSimpleEvent('fullscreenchange', document, {bubbles:true})
}
}, false)

function fireSimpleEvent(type, target, option) {
if (!target) target = document
if (!option) option = {}
var evt = document.createEvent('Event')
evt.initEvent(type, !!option.bubbles, !!option.cancelable)
return target.dispatchEvent(evt)
}

fullscreen应用实例:我自己的演讲slides都是用HTML5的,在全屏时进入slides状态。例子见:
http://hax.github.com/2011/es5_safety/ ,Chrome/FF中按F11可以看到效果。


2011/8/5 Zi Bin Cheah <zibin@opera.com>

> 全屏对HTML5 apps发展应该是很重要的,**apps如果没法控制全屏就没有办法达到native的效果,**
> 比方html5游戏还是给人网页的感觉,而非一个game。
>
> Mozilla提出了Fullscreen API[1],webkit也会使用它[2]。
>
> 比方调用video全屏
>
> <video src="pelican.webm" autoplay
>       onclick="event.target.**requestFullScreen()"
>       onended="document.**cancelFullScreen()">
> </video>
>
> 最大的隐忧是全屏是否应该得到用户的允许下才能进行(**explicit permission),而且也存在这其他安全问题。
>
>
> [1]https://wiki.mozilla.org/**Gecko:FullScreenAPI<https://wiki.mozilla.org/Gecko:FullScreenAPI>
> [2]http://lists.whatwg.org/**htdig.cgi/whatwg-whatwg.org/**
> 2011-May/031538.html<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/031538.html>
>
>
>
>

Received on Friday, 5 August 2011 18:17:06 UTC