Javascript Christmas Cards
Revision as of 14:59, 1 December 2011 by Michael Murtaugh (talk | contribs) (Created page with "<source lang="html4strict"> <!DOCTYPE html> <html> <head> <script> function domything () { var x = document.getElementById("xmas"); // console.log("x is", x, x.currentTi...")
<!DOCTYPE html>
<html>
<head>
<script>
function domything () {
var x = document.getElementById("xmas");
// console.log("x is", x, x.currentTime, x.duration);
x.currentTime = x.duration / 2;
}
function start () {
var x = document.getElementById("xmas");
x.addEventListener("durationchange", domything, false);
x.addEventListener("play", function () {
body =document.getElementsByTagName("body")[0];
body.style.background = "black";
}, false);
x.addEventListener("pause", function () {
body =document.getElementsByTagName("body")[0];
body.style.background = "";
}, false);
x.addEventListener("timeupdate", function () {
if (x.currentTime > 56) {
x.currentTime = x.duration / 2;
}
}, false);
}
document.addEventListener("DOMContentLoaded", start, false);
</script>
</head>
<body>
<center>
<video id="xmas" controls src="Prozim-Christmas863.ogv">No video support!</video>
</center>
</body>
</html>