/    Sign up×
Community /Pin to ProfileBookmark

if statement

Hello!

I’ve picked up this code from the book:

[code]
<html>
<head>
<script language = “javascript”>
[COLOR=limegreen]if (document.images)[/COLOR]
{
image1 = new Image
image2 = new Image
image1.src = “my secondimage.gif”
image2.src = “myfirstimage.gif”
}
else
{
image1 =””
image2 =””
}

</script>
</head>

</html>

[/code]

The text that is highlighted I don’t understand quite well.
That means if document.images are true, equals to zero, or equals to
one? document.images I don’t see that images was declared anywhere in the code.
This is something related to rollover. There is some code that goes in the body text which I understand pretty well.

Thanks.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PittimannFeb 19.2005 — Hi!

document.images is an array containing the image objects of a document. Most browsers use this array. The if statement checks the availability of that array (and thus, to make it simple: the browser's capability to deal with images at all). So, if the array is there, do some stuff, if not, do other stuff.

Cheers - Pit
Copy linkTweet thisAlerts:
@barimauthorFeb 19.2005 — So, that means that there are some browsers that are incapable of handling images at all? I would like to know what type of browswers cannot handle images? I wonder if such broswers exist at all.

If you could provide me this information, so I can see usefulness of this if statement.

Thanks a lot.
Copy linkTweet thisAlerts:
@JPnycFeb 19.2005 — Type "text only browsers" or "non-graphical" browsers into any search engine.
×

Success!

Help @barim spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...