简体   繁体   English

在计时器内设置时,HTML5全屏无法正常工作

[英]HTML5 full-screen doesn't work when set inside a timer

I am trying this code. 我正在尝试此代码。 It is supposed to generate an image and set its container div to full-screen when the p is clicked. 单击p时,它应该会生成图像并将其容器div设置为全屏。

<html>
<head>
<style>
img { height: 643px; width: 860px; }
img:-moz-full-screen { height: 643px; width: 860px; }
div:-moz-full-screen { background: white; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
$(function() {
 $("p").click(function() {    
  setTimeout(function() {
    $("body").prepend("<div><img src = 'http://i.stack.imgur.com/lBZKC.jpg?s=128&g=1' /></div>");
    $("div").get(0).mozRequestFullScreen();
  },5000);
 });
});
</script>
</head>
<body>
<p>Foo</p>
</body>

What it does is wiat for 5 seconds and prepend the image all right, but it is not set to full-screen. 它的作用是先等待5秒钟,然后在图像之前添加好所有内容,但未将其设置为全屏。 However, if you remove the timer and do it normally: 但是,如果您删除计时器并正常进行操作:

$("p").click(function() {
  $("body").prepend("<div><img src = 'http://i.stack.imgur.com/lBZKC.jpg?s=128&g=1' /></div>");
  $("div").get(0).mozRequestFullScreen();
});

it works fine, it prepends the image and immediately sets it to full-screen. 它可以正常工作,它会预先添加图像并立即将其设置为全屏显示。

Is this intentional, or a bug? 这是故意的还是错误? Either way, is there any way to make it work? 不管哪种方式,有什么方法可以使它起作用?

必须响应于用户输入事件(例如,按键,鼠标事件)来调用该方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 完成后重定向全屏自动播放HTML5视频 - Redirect full-screen autoplaying HTML5 video when finished 当我将它与React全屏组件一起使用时,屏幕上的React无法正常工作 - React on screen doesn't work when I use it with React full-screen component 如何在单个HTML5全屏模式下显示2个视频 - How to show 2 videos in single HTML5 Full-screen mode 无法在全屏覆盖模式内居中图像 - Can't center the image inside of a full-screen overlay modal 微小的MCE - 在加载编辑器时设置全屏? - Tiny MCE - set full-screen when editor is loaded? 在iPad和Android平板电脑上强制播放全屏HTML5视频? - Force full-screen HTML5 video playback on iPad and Android tablets? 按下用于视频而不用于弹出窗口的esc按钮后,如何以全屏模式打开包含HTML5视频的引导弹出窗口? - How to keep the bootstrap popup opened containing HTML5 video on full-screen mode after pressing esc button intended for the video not for the popup? 猫头鹰轮播全屏不起作用 - Owl carousel full screen doesn't work 无溢出:具有页脚和导航栏的全屏轮播HTML CSS JS - No overflow: Full-screen Carousel with footer and navbar HTML CSS JS 如何将html拆分为全屏高度页面? - How to split html to full-screen height pages?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM