Reputation: 247
I have an html file that uses JavaScript to display a clock. I want to modify this html to also play a looped video below the clock. However, the video does not display if I have the clock active; it works when I deactivate the clock (comment out the clock divs). Does anyone know how I can fix this? Sorry for the tangled mess of CSS/HTML/JavaScript.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>Javascript Clock</title><script language="JavaScript" type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
var day = today.getDate();
var month = today.getMonth() + 1;
var year = today.getFullYear();
var hsec=Math.floor(today.getMilliseconds());
// add a zero in front of numbers<10
document.getElementById('txt').innerHTML=h+":"+checkTime(m)+":"+checkTime(s)+":"+checkHTime(hsec);
document.getElementById('cal').innerHTML=checkTime(month)+"/"+checkTime(day)+"/"+year;
setTimeout('startTime()',10);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
function checkHTime(i)
{
if (i<100)
{
if (i<10)
{
i="0" + i;
}
i="0" + i;
}
return i;
}
</script></head>
<body onload="startTime()" bgcolor="black">
<center><br><br><br><img style="width: 776px; height: 133px;" alt="ad" src="ad-logo-pms2945% 20png.png"><br><br>
<div id="txt" style="font-family: serif; font-size: 30pt; font-weight: bold; color: red;">00:00:00:00</div>
<div id="cal" style="font-family: serif; font-size: 30pt; font-weight: bold; color: red;>"00/00/0000</div>
<div id="video">
<video id="duck-movie" height="240">
<source src="duck.mp4" type="video/mp4">
Video is unavailable
</video>
</div>
</center>
</body></html>
EDIT: If I move the "video" div above the "txt" and "cal" divs, the video plays and the clock runs fine.
Upvotes: 0
Views: 74
Reputation: 306
You use a HTML 4.01 doctype for this, but the video tag isn't part of HTML 4.01. Try replacing your current doctype with
<!DOCTYPE html>
Upvotes: 2