473,398 Members | 2,368 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,398 software developers and data experts.

Image complete property prematurely true?

I've been playing around with some means of testing image loading, and
noticing that the "complete" property seems to default to true. Trying
the following in the squarefree javascript shell:

I = new Image();
I.complete

yields "true".

Seems a bit odd -- obviously there's no src given yet, so is it
really complete? Is this behavior defined that way on purpose? If so,
what's the justification?

Apr 2 '07 #1
4 7656
Weston said the following on 4/2/2007 11:49 AM:
I've been playing around with some means of testing image loading, and
noticing that the "complete" property seems to default to true. Trying
the following in the squarefree javascript shell:

I = new Image();
I.complete

yields "true".
Run it in IE7, it gives false.
Seems a bit odd -- obviously there's no src given yet, so is it
really complete? Is this behavior defined that way on purpose? If so,
what's the justification?
Why not use the onload event of the image?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 2 '07 #2
On Apr 2, 12:18 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Weston said the following on 4/2/2007 11:49 AM:
I've been playing around with some means of testing image loading, and
noticing that the "complete" property seems to default to true. Trying
the following in the squarefree javascript shell:
I = new Image();
I.complete
yields "true".

Run it in IE7, it gives false.
Interesting. I should have specified... Camino 1 and Firefox 2 yield
true. Safari doesn't seem to run the squarefree shell, but using the
Mochikit Interpreter (http://mochikit.com/examples/interpreter/
index.html ) also yields true.

Can you verify that with IE7, once you specify a valid image url for
the src property, complete switches to true?

Can anyone verify that IE6 does the same?
Why not use the onload event of the image?
That's probably the path I'll end up taking for the practical
application of this investigation -- this line of investigation is
mostly curiousity. But since we're talking about it: are the onload /
onerror handlers part of a specific standard, or even just pretty
consistent across browsers?

I've also been looking at testing against the default value of the
"width" property (-1 in Moz/Gecko, 0 in Safari). Not ideal in a number
of situations, given that there could well be lagtime between where
the test is interpreted and the load of the image, but like the
complete property, it seems be more convenient in branches of code
where you're sure the image should already have been loaded if it was
going to load at all.

Apr 2 '07 #3
On Apr 2, 12:18 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Run it in IE7, it gives false.

Can you verify that with IE7, once you specify a valid image url for
the src property, complete switches to true?
I've just verified this from a friend -- IE7 will switch complete to
true once you give it a good src (forgot to have him verify that
complete remains false if it can't load the given URL, tho').

Why not use the onload event of the image?

... are the onload / onerror handlers part of a specific standard,
or even just pretty consistent across browsers?
I've just checked, and onerror doesn't seem to work in Safari. This
code:

I = new Image()
I.onerror = function () { alert('failure'); }
I.onload = function () { alert('loaded'); }
I.src = 'http://bogus.fak/fake.jpg'

results in the 'loaded' alert coming up.

This means you have to run a check in the onload function... and since
it can't be "complete", it's probably going to have to be something
like checking the default image width value against the loaded image
value.
Apr 2 '07 #4
Weston said the following on 4/2/2007 12:54 PM:
On Apr 2, 12:18 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>Weston said the following on 4/2/2007 11:49 AM:
>>I've been playing around with some means of testing image loading, and
noticing that the "complete" property seems to default to true. Trying
the following in the squarefree javascript shell:
I = new Image();
I.complete
yields "true".
Run it in IE7, it gives false.

Interesting. I should have specified... Camino 1 and Firefox 2 yield
true. Safari doesn't seem to run the squarefree shell, but using the
Mochikit Interpreter (http://mochikit.com/examples/interpreter/
index.html ) also yields true.

Can you verify that with IE7, once you specify a valid image url for
the src property, complete switches to true?
No it doesn't.
Can anyone verify that IE6 does the same?
>Why not use the onload event of the image?

That's probably the path I'll end up taking for the practical
application of this investigation -- this line of investigation is
mostly curiousity. But since we're talking about it: are the onload /
onerror handlers part of a specific standard, or even just pretty
consistent across browsers?
IE7 won't fire the onload using a local image. Didn't try it with an
online image.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 2 '07 #5

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

Similar topics

1
by: Adam Ratcliffe | last post by:
I'm trying to come up with a solution for detecting when an image, loaded by a script, has completely loaded. The Image.onload event is fired after the image has loaded in Firefox but before...
2
by: Charles Harrison Caudill | last post by:
I'm trying to write a function to determine whether or not an image exists. Most people recommend setting the onload event handler. That works like a charm except that side-effective actions...
2
by: moondaddy | last post by:
I need to get the size on an image client side before the client uploads it, and if its too large, I need to alert the client rather than doing a postback. The code below successfully writes the...
6
by: anonymous | last post by:
hi all, I'm trying to use the capCreateCaptureWindow (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_capcreatecapturewindow.asp) in a Windows...
2
by: Marc Solé | last post by:
Hello, I want to insert an image to a specific column of a dataGridWiew. I explain what I'm doing: - I define the ColumnType as a DataGridViewImageColumn. - I select the image (an icon of...
0
by: David | last post by:
Hello all. I am trying to implement my first server control and have run into two problems that I cannot solve. I need the assistance of someone with more experience. My goal was to create an...
11
by: Adam Sandler | last post by:
Hello, Having an issue with JavaScript in my ASP.Net page. I use some COTS, which for all intents and purposes, simply makes a jpeg file and physically places it in a directory on the web...
6
by: Janwillem Borleffs | last post by:
Tuxedo schreef: You can check the Image.complete property; example: img = new Image(100,100); interval = setInterval('checkcomplete()', 100); img.src = 'someimg'; function checkcomplete()...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...

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.