473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

my document.images code is not correct

7
Can someone tell me what I did wrong in the following code? Thanks


[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Arai</title>

<script type="text/javascript">
function albumload() {
var album = new Array();
var i;
var pages = 2;

for (i = 0; i <pages; i++) {
//alert(i);
album[i] = new Image();
album[i].src = "picture"+i+".jpg";
// I have 2 pictures named picture0.jpg and picture1.jpg
// I am hoping to show the pictures on screen
// The debugger said the following code document.images..
// is null or not an object
document.images[i].src = album[i].src ;
document.write("<img src='images[i]'/>");
}
}

</script>
</head>
<body onload="albumload()">
<script type="text/javascript">
</script>
</body>
</html>[/HTML]
Dec 1 '07 #1
2 1357
acoder
16,027 Expert Mod 8TB
1. Don't use document.write after the page has loaded.
2. There are no images on the page, so document.images does hot have any items. Add two img tags to the page.
Dec 1 '07 #2
aayybb
7
1. Don't use document.write after the page has loaded.
2. There are no images on the page, so document.images does hot have any items. Add two img tags to the page.

If I included the following code

document.write("<img scr = 'picture1.jpg'/>");

then the picture will show on the screen.

I don't understand why the following code is not working.

document.write("<img src='images[i]'/>");
Dec 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: duane | last post by:
Dear Experts: I have a problem. When you enter the website I am working on, wherever you go within the website, the URL address on the website will display: "http:\\..\index.html", whether...
1
by: Winfried Koenig | last post by:
Hi everyone, I have a main page: -------------------------------------------------- <html><head><title>Test</title> </head><body> <img id="img_a" name="img_a" src="image_1.png" alt=""><br>
8
by: Jean Pierre Daviau | last post by:
for (var i=0; i< document.images.lenght; i++){ totalWidth = totalWidth + document.images.width; totalHeight = totalHeight + document.images.height; } -- X trême newbe ....... masm32 windows...
6
by: Bob Alston | last post by:
I am looking for others who have built systems to scan documents, index them and then make them accessible from an Access database. My environment is a nonprofit with about 20-25 case workers who...
4
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
4
by: tswaters | last post by:
Alright, so generally I'm using document.createElement("IMG").... but, I've noticed something just recently that made me switch to "new Image()" What I'm doing is creating a photo gallery of...
10
by: AC | last post by:
I had a page that does some event setup on window.onload: function prepEvents() { document.getElementById("menumap_sales").onmouseover = swapMenuSales; // etc } window.onload = prepEvents;
6
by: mistral | last post by:
what is correct way open a PDF document in new window use hyperlink? I want show images thumbnails linked with PDF files, when click on thumbnail, PDF will be opened in new window. Some of PDF...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.