我试图为我自己的实践/喜悦做的Im项目撰写一个没有J Query的横向梯子。
相关法典:
function moveit() {
"use strict";
document.getElementById("position").style.left = window.event.clientX + "px";
}
window.onload = function () {
"use strict";
findtime();
document.getElementById("scrollbar").style.width = document.getElementById("thevideo").offsetWidth + "px";
var mousemove;
document.getElementById("scrollbar").onclick = function () {
mousemove = window.setInterval("moveit()", 1000);
};
document.getElementById("scrollbar").mouseup = function () {
window.clearInterval(mousemove);
};
};
不用说我有问题。 它经常产生 Chrome、 Firefox、 Firefox等错误:
Uncaught TypeError: Cannot read property clientX of undefined
然而,如果我掌握以下法典的话,它就能够发挥作用(但对于采取改变立场并不有用):
document.getElementById("position").style.left = 12 + "px";
传真如下:
<?php include("header.php"); ?>
<div>
<video id="thevideo">
<source src="movie.ogv" type="video/ogg" />
</video>
</div>
<div>
<span id="currenttime" contenteditable="true">0:00</span> / <span id="totaltime"></span>
</div>
<div id="scrollbar">
<div id="position" draggable="true"></div>
</div>
<?php include("footer.php"); ?>