Javascript Christmas Cards: Difference between revisions

From XPUB & Lens-Based wiki
(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...")
 
No edit summary
 
Line 4: Line 4:
<head>
<head>
<script>
<script>


function domything () {
function domything () {
Line 9: Line 10:
     // console.log("x is", x, x.currentTime, x.duration);
     // console.log("x is", x, x.currentTime, x.duration);
     x.currentTime = x.duration / 2;
     x.currentTime = x.duration / 2;
    x.play();
}
}


Line 27: Line 29:
         }
         }
     }, false);
     }, false);


}
}
Line 38: Line 39:
<body>
<body>
<center>
<center>
<video id="xmas" controls src="Prozim-Christmas863.ogv">No video support!</video>
<video id="xmas" controls src="video/Prozim-Christmas863.ogv">No video support!</video>
<br />
Video by <a href="http://www.archive.org/details/Prozim-Christmas863">Utah Valley Handbell Choir</a>
 
</center>
</center>
</body>
</body>


</html>
</html>

Latest revision as of 14:59, 1 December 2011

<!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;
    x.play();
}

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="video/Prozim-Christmas863.ogv">No video support!</video>
<br />
Video by <a href="http://www.archive.org/details/Prozim-Christmas863">Utah Valley Handbell Choir</a>

</center>
</body>


</html>

LIVE