473,804 Members | 3,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.images


for (var i=0; i< document.images .lenght; i++){
totalWidth = totalWidth + document.images[i].width;
totalHeight = totalHeight + document.images[i].height;
}
--

X trême newbe
.......
masm32
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
Jul 23 '05 #1
8 2529
Jean Pierre Daviau wrote:
for (var i=0; i< document.images .lenght; i++){
'lenght' ? (sp)
totalWidth = totalWidth + document.images[i].width;
totalHeight = totalHeight + document.images[i].height;
totalWidth += document.images[i].width;
totalHeight += document.images[i].height;
}
--

X trême newbe
......
masm32
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz


We will now consult the oracle, hoping to divine your question.

Jul 23 '05 #2
Ha, ha!

And the question is . . .

the [i] does not seem to be red as a number.
alert(totalWidt h) gives 0.
We will now consult the oracle, hoping to divine your question.


After all it is signed
X treme newbe

Thank you for reading.

Jul 23 '05 #3
Jean Pierre Daviau wrote:
Ha, ha!

And the question is . . .

the [i] does not seem to be red as a number.
alert(totalWidt h) gives 0.
We will now consult the oracle, hoping to divine your question.


After all it is signed
X treme newbe

Thank you for reading.


Now there's a problème !

Always post as much of what you're doing as seems reasonable. Are you
running this script in the <head>er of the document? Source files are
read from beginning-to-end (top to bottom as they appear in your
editor). Can't rummage through a collection (document.image s) that
hasn't been made yet. Always hook these up to an onload handler:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript">

function getImageDims()
{
var totalWidth = totalHeight = 0;
for (var i = 0; i < document.images .length; i++)
{
totalWidth += document.images[i].width;
totalHeight += document.images[i].height;
}
alert('total width: ' + totalWidth + '\ntotal height: ' +
totalHeight);
}

window.onload = getImageDims; //no ()!

</script>
</head>
<body>
<img src="http://www.4girls.gov/nutrition/apple-small.jpg">
<img src="http://www.chrisgilman .com/APPLE_small1.jp g">
<img src="http://allthatchocolat e.com/images/products/apple_small.jpg ">
</script>
</body>
</html>

Image objects have their own onload handlers (like the window, above -
so:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript">

var totalWidth = totalHeight = 0;

function getImageDims()
{
alert('total width: ' + totalWidth + '\ntotal height: ' +
totalHeight);
}

window.onload = getImageDims;

</script>
</head>
<body>
<img src="http://www.4girls.gov/nutrition/apple-small.jpg"
onload="totalWi dth+=this.width ;totalHeight+=t his.height">
<img src="http://www.chrisgilman .com/APPLE_small1.jp g"
onload="totalWi dth+=this.width ;totalHeight+=t his.height">
<img src="http://allthatchocolat e.com/images/products/apple_small.jpg "
onload="totalWi dth+=this.width ;totalHeight+=t his.height">
</script>
</body>
</html>

Jul 23 '05 #4
function ready(){
var largeur = screen.availWid th;
var hauteur = screen.availHei ght;
var n = document.images .lenght;
var totalWidth = 0;
var totalHeight = 0;

for (var i=0; i< n; i++){
totalWidth = totalWidth + document.images[i].width;
totalHeight = totalHeight + document.images[i].height;
}
var wspacer = (largeur/totalWidth)/(n+1);
var hspacer = (hauteur/totalHeight)/(n+1);
alert(wspacer); ============NaN
alert(totalWidt h); ============0
}

<body onLoad="ready() ">
Jul 23 '05 #5

"Jean Pierre Daviau" <On**@WasEno.ug h> wrote in message
news:mV******** **************@ wagner.videotro n.net...
function ready(){
var largeur = screen.availWid th;
var hauteur = screen.availHei ght;
var n = document.images .lenght;
var n = document.images .length;
I suspect this typo has been persisting since the original post

var totalWidth = 0;
var totalHeight = 0;

for (var i=0; i< n; i++){
totalWidth = totalWidth + document.images[i].width;
totalHeight = totalHeight + document.images[i].height;
}
var wspacer = (largeur/totalWidth)/(n+1);
var hspacer = (hauteur/totalHeight)/(n+1);
alert(wspacer); ============NaN
alert(totalWidt h); ============0
}

<body onLoad="ready() ">

Jul 23 '05 #6
My second post with the question dissapeared somewhere.

I am posting with OutlookExpress. Is there a problem with that on the
newsgroup server?

"J. J. Cale" <ph****@netvisi on.net.il> a écrit dans le message de news:
4261e043
| var n = document.images .length;
| I suspect this typo has been persisting since the original post

If I write alert(document. images[0].width+document .images[1].width) it gives
271 . Witch is OK.

If I use a for loop, I get 0. Why ?


Jul 23 '05 #7
Jean Pierre Daviau wrote:
My second post with the question dissapeared somewhere.
Try putting the question in the same post as the code.
I am posting with OutlookExpress. Is there a problem with
that on the newsgroup server?
Outlook express can be successfully used for posting to newsgroups,
though it probably takes more effort on the part of its users to get the
posting format correct than some of the alternatives.
J. J. Cale wrote:
| var n = document.images .length;
| I suspect this typo has been persisting since the original
| post

If I write alert(document. images[0].width+document .images[1].width)
it gives 271 . Witch is OK.

If I use a for loop, I get 0. Why ?


The point that J.J.Cale is making is that "lenght" is a misspelling of
"length" and as the form will not have a "lenght" property the - n -
variable will be assigned the value - undefined -. Then when - i < n -
is evaluated (where - i - is numeric) - n - will be type-converted to a
number, and that number is NaN. All comparisons with NaN return false so
the body of the - for - loop is never executed and the - totalWidth -
and - totalHeight - variables retain the value to which they were
initialised; zero.

On the whole the scheme seems potty though. There is no useful
relationship between the screen.availWid th/Height values and anything
that happens within the viewport of a web browser (not even that the
dimensions of the viewport will be less than the avialWidth/Height).

Richard.
Jul 23 '05 #8

"Richard Cornford" <Ri*****@litote s.demon.co.uk> a écrit dans le message de
news: d3************* ******@news.dem on.co.uk...
| Jean Pierre Daviau wrote:
| > My second post with the question dissapeared somewhere.
|
| Try putting the question in the same post as the code.
|
| > I am posting with OutlookExpress. Is there a problem with
| > that on the newsgroup server?
|
| Outlook express can be successfully used for posting to newsgroups,
| though it probably takes more effort on the part of its users to get the
| posting format correct than some of the alternatives.
|
| > J. J. Cale wrote:
| >| var n = document.images .length;
| >| I suspect this typo has been persisting since the original
| >| post
| >
| > If I write alert(document. images[0].width+document .images[1].width)
| > it gives 271 . Witch is OK.
| >
| > If I use a for loop, I get 0. Why ?
|
| The point that J.J.Cale is making is that "lenght" is a misspelling of
| "length" and as the form will not have a "lenght" property the - n -
| variable will be assigned the value - undefined -. Then when - i < n -
| is evaluated (where - i - is numeric) - n - will be type-converted to a
| number, and that number is NaN. All comparisons with NaN return false so
| the body of the - for - loop is never executed and the - totalWidth -
| and - totalHeight - variables retain the value to which they were
| initialised; zero.
|
| On the whole the scheme seems potty though. There is no useful
| relationship between the screen.availWid th/Height values and anything
| that happens within the viewport of a web browser (not even that the
| dimensions of the viewport will be less than the avialWidth/Height).
|
| Richard.
Thank you very much
Jul 23 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
10115
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>
2
1954
by: Aaron | last post by:
Hi, I've seen javascript code where a constructor function is passed an argument "document", and inside the function itself the assignment "this.document = document;" is made. This is the code (or the part necessary for the example): function ToggleButton(document) { ToggleButton.images = new Array(4); for(i=0;i<4;i++) { ToggleButton.images = new
4
5485
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById(nameOfDiv).style.visibility='visible'; document.getElementById(nameOfDiv).style.height='auto'; if (nameOfDiv != 'weblogs')
9
3945
by: Jeff | last post by:
I get the following error when I try to rollover my button: document.images has no properties Line: 22 Am I doing this correctly? Suggestions? This is using Netscape 7.2 on Fedora core 4. Here's my simple html file: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
6
3878
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 use laptops. They have Access databases on their laptops and the data is replicated. The idea is that each case worker would scan their own documents, either remotely or back at the office. And NO I am not planning to store the scanned...
6
7239
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to display an image. document.images only seems to reference image tags. The collection needs to include background images, input type = image, image maps, css assigned background, etc. Honestly, I am probably not aware of all the possibilities...
7
1285
by: Draenox | last post by:
In an if statement with "document.images" as it's expression, does it simply check if there are any image elements in an HTML page? I'm assuming if it finds any that the expression will return true and execute the statements within the if. if(document.images) { // various statements.... }
4
2647
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 iframe's src property. Being that IE does not follow standard and considers an id, name, etc as a qualifying identifier for the document.getElementById object, I double checked to make sure that there's only one instance of id = "servif" and I never use...
10
3780
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;
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10580
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.