Document.images.length DOESN'T WORK

HI, I have got sth like this:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
http://www.w3.org/TR/html4/strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<title>Szablon JavaScript</title>
<meta http-equiv=“content-type” content=“text/html;charset=ISO-8859-2” />
<link rel=“stylesheet” href=“style.css” type=“text/css” />
<script type=“text/javascript” src=“skrypt.js” charset=“ISO-8859-2”></script>
</head>
<body>
<img name=“obrazek1” src=“rys1.gif” />
</body>
</html>
and script:
document.write(document.images.length);
The result of this script is 0, but there is a one image. Anyone knows why it’s 0?
And the second example, which doesn’t work:
:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<title>Chapter 6: Example 3</title>
</head>
<body>
<img name=”img1” src=”” border=”0” width=”200” height=”150” />
<script type=”text/javaScript”>
var myImages = new Array(“usa.gif”,”canada.gif”,”jamaica.gif”,”mexico.gif”);
var imgIndex = prompt(“Enter a number from 0 to 3”,””);
document.images[“img1”].src = myImages[imgIndex];
</script>
</body>
</html>
This script should change image if user put different number, but it does NOTHING and I dont know why

At the ime that the script runs, the rest of the page doesn’t exist yet, which is why you’re getting 0.

The main problem that immediately stands out there is that fancy quotes are used, which are not accepted by HTML. You need to use double quotes there instead.

you’re absolutely right!!! Now everything is clear!!! Thank U so much!!

Do you know why this code doesn’t work? If images are in <ul></ul> doesn’t work, but if images are outside <ul></ul> it is OK:

<ul>
<li><img src=“fot1.jpg” id=“fot1”/></li>
<li><img src=“fot2.jpg”/></li>
<li><img src=“fot3.jpg”/></li>
</ul>
<input type=“button” onclick=“enlarge()” value=“Zmien rozmiar” />

and script:

function enlarge(){
document.images[0].width *= 1.2;
}

It seems to work for me whether they are in or out of the list area.

Perhaps there’s something else about the page that’s causing interference.
Can you please link us to a test page that demonstrates the problem?