我有这个用于webkitRequestFullScreen的JSFiddle示例.
我在Mac OSX上使用Chrome 2,该示例似乎对我不起作用.最初我写了我自己的例子,但下面链接中的那个不是我写的.它仍然似乎没有用.
var test = document.querySelector('.test');
test.addEventListener('click', function () {
if(test.requestFullScreen) {
test.requestFullScreen();
} else if(test.mozRequestFullScreen) {
test.mozRequestFullScreen();
} else if(test.webkitRequestFullScreen) {
test.webkitRequestFullScreen();
}
}, false);
Run Code Online (Sandbox Code Playgroud)
但以下示例确实有效!只有当我尝试在Plunker或JSFiddle中重现它时,它似乎不起作用:
http://www.jwplayer.com/blog/using-the-browsers-new-html5-fullscreen-capabilities/
继承人我的掠夺者例子:
<!-- just to keep things in one place I put the JS here. -->
<script type="text/javascript">
function goFullscreen(id) {
// Get the element that we want to take into fullscreen mode
var element = document.getElementById(id);
// These function will not exist in the browsers that don't support fullscreen mode yet,
// so we'll have to check to see if they're available before calling them.
if (element.mozRequestFullScreen) {
// This is how to go into fullscren mode in Firefox
// Note the "moz" prefix, which is short for Mozilla.
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
// This is how to go into fullscreen mode in Chrome and Safari
// Both of those browsers are based on the Webkit project, hence the same prefix.
element.webkitRequestFullScreen();
}
// Hooray, now we're in fullscreen mode!
}
</script>
<div class="example">
<img class="video_player" src="http://assets3.parliament.uk/iv/main-large//ImageVault/Images/id_7382/scope_0/ImageVaultHandler.aspx.jpg" id="player2">
<button onclick="goFullscreen('player2'); return false">Click Me To Go Fullscreen! (For real)</button>
</div>
Run Code Online (Sandbox Code Playgroud)
http://plnkr.co/edit/BOhqNTEACTPmr9ebVnHs?p=preview
有任何想法吗?我很困惑!
小智 8
WebKit的版本不大写s的Fullscreen.
小智 5
对于其他人,我发现这个线程说如果您为元素(div 等)调用它,它在 iPhone 上不起作用:https : //developer.apple.com/forums/thread/133248
| 归档时间: |
|
| 查看次数: |
11225 次 |
| 最近记录: |