我是这个世界上的新人。我不会质疑承诺^^‘的每一步,但是,我遵循的是一个非常好的教程,但是问题出现在JS中的< video >标记部分,它来自2014...so,此后可能会有更新。好吧,当我希望按下"Play“按钮时,我无法使<视频>工作。我已经完成了与他相同的操作+可能的更新(比如:Simple“()”,输入源代码,等等)。Nothing :/ ,但是,如果我将它添加到HTML中(< script >标记),它会工作.
<!DOCTYPE html>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>CANARIAS</title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1404.47">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="main.js">
</head>
</script>
<body>
<section id="video">
<video id="mivideo" width="720" loop>
<source src="/video/video-2012-04-05-14-22-32.mp4" type="video/mp4">
<source src="/video/video-2012-04-05-14-22-32.ogg" type="video/ogg">
<source src="/video/video-2012-04-05-14-22-32.webm" type="video/webm">
</video>
<nav>
<div id="botones">
<button type="button" id="reproducir">Play</button>
</div>
<div id="barra">
<div id="progreso"></div>
</div>
</nav>
</section>
</body>
</html>JAVASCRIPT
var mivideo, reproducir, barra, progreso;
function comenzar() {
mivideo = document.getElementById("mivideo");
reproducir = document.getElementById("reproducir");
barra = document.getElementById("barra");
progreso = document.getElementById("progreso");
reproducir.addEventListener("click", clicando, false);
progreso.addEventListener("click", adelantando, false)
}
function clicando() {
if ((mivideo.paused==false) && (mivideo.ended==false)) {
mivideo.pause();
reproducir.innerHTML = "Play";
}
else {
mivideo.play();
reproducir.innerHTML = "Pause";
}
}
window.addEventListener("load", comenzar, false);发布于 2020-06-21 13:09:28
如果您认为它对内部Js很好,而对外部Js则不行,那么我认为问题在于您还没有将JavaScript文件与HTML链接起来。
查看完整指南如何以及在何处正确链接HTML中的Js文件.
https://stackoverflow.com/questions/62496283
复制相似问题