gpt4 book ai didi

jquery - 未捕获的类型错误 : Object # has no method 'webkitEnterFullScreen'

转载 作者:行者123 更新时间:2023-12-01 08:15:42 24 4
gpt4 key购买 nike

我尝试在弹出窗口中使用 html5 全屏 api,但我不断收到此错误:

Uncaught TypeError: Object #<HTMLElement> has no method 'webkitEnterFullScreen' 

这是我的 html :

<html lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Negar - one</title>
<script type="text/javascript" src="/Negar/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/Negar/js/viewer.js"></script>
<style type="text/css">
#main-content{height: 100%; width: 100%; position: absolute;
-webkit-transition: -webkit-transform 1s ease-in;
-moz-transition: -moz-transform 1s ease-in;
-ms-transition: -ms-transform 1s ease-in;
transition: transform 1s ease-in;
}
</style>
</head><link rel="stylesheet" type="text/css" href="data:text/css,">

<body>
<section id="main-content"> some code here </section>

</body></html>

这是我的功能:

$("#main-content").get(0).webkitEnterFullScreen();

最佳答案

进入全屏的请求可能应该由用户发出。您可以尝试这样的事情来实现您想要做的事情:

<script>
function goFs(id) {
var element = document.getElementById(id);

if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
}
</script>

<div id="test">
Hi there!
</div>

<button onclick="goFs('test');">Full screen?</button>

示例:http://fiddle.jshell.net/73Wus/show/

注意:我必须共享完整的 jsFiddle 页面,因为 iframe 需要特殊属性才能允许全屏,如下所示:

<iframe src="127.0.0.1" allowFullScreen></iframe>

...常用的Fiddle可以找到here .

关于jquery - 未捕获的类型错误 : Object #<HTMLElement> has no method 'webkitEnterFullScreen' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10859045/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com