Forum Moderators: open
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
window.onload = function(){chgDailyImg();}
function chgDailyImg()
{
var imagearray = new Array('quote1.jpg','quote2.jpg','quote3.jpg','quote4.jpg');
var d = new Date();
var t = d.getTime();
var days = Math.floor(t/(86400000));
var i = days % imagearray.length;
Document.getElementById("dailyImg").src = imagearray[i];
}
</script>
</head>
<body>
<h1> <b> HI THERE GUYS! THIS PIC WILL CHANGE EVERYDAY. </b> </h1>
<img src=imagearray[i] title="daily quote" width="600" height="400" id="dailyImg" />
</body>
</html>
src=imagearray[i] img src=imagearray[i]
(in the way that you're using it, not as literal text) only has meaning inside a <script> section. In some situations you could use innerHTML with the element's id, but it's obviously not possible in a self-closing element such as <img>. In any case you need a fallback for people with scripting turned off. Also, an H1 header is bold by default, so adding <b></b> has no effect.Besides, you should be styling your own headers unless you're striving for that 1997 Retro Look. Bold or not-bold, to taste, but it certainly doesn't need to be inside the <h1> tags -- unless this specific page is for some reason meant to look different from all the other <h1> on the rest of the site.
here is your code, corrected and validated...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
<title>untitled document</title>
<style media="screen">
#dailyImg {
display: block;
width: 100%;
max-width: 37.5em;
height: auto;
}
</style>
</head>
<body>
<h1>HI THERE GUYS! THIS PIC WILL CHANGE EVERYDAY.</h1>
<img id="dailyImg" src="quote1.jpg" width="600" height="400" alt="daily quote">
<script>
var imagearray = ['quote1.jpg','quote2.jpg','quote3.jpg','quote4.jpg'];
var d = new Date();
var t = d.getTime();
var days = Math.floor(t/(86400000));
var i = days % imagearray.length;
document.getElementById('dailyImg').src = imagearray[i];
</script>
</body>
</html>
2) "Document..." & "document...." dont change a thing. I tried both.