[英]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.