faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 10 people (50%) answered Yes
Recently 4 of 8 people (50%) answered Yes

Entry

How to determine with JavaScript if images are shown (i.e., not disbled) in a browser?

Apr 5th, 2008 19:25
ha mo, Paco Calvo, Colin Fraser,


try 
<IMG SRC="myimage.gif" height=120 width=150 onError="alert('This image 
has not loaded')">
Later browsers support the Image object, so this will at least alert 
the user that images are not loading, 
However, with most browsers supporting images and most internet 
connections faster and faster, fewer people are turning images off, so 
it may be that the user has deliberately turned images off, for their 
own reasons. A constant reminder of this is sure to piss them off.
==========
Paco Calvo
Well, after leaving that question aside, I've found a (partial) easy 
way:
You have to test the 'complete' attribute of an image: in IE 4+ it 
returns false if images are not shown (in NN it returns 'true' always)
Also, you have to set a timer to test that attibute, because with 
OnLoad in IE4+ you get the value 'false', and, after all, OnLoad isn't 
called with images not shown in that browser. Of course, you have to 
manually select a value for the timer that is suitable for your 
situation.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com