I can't get IE to use onError="alert('Connection error.')" on the <img> tag.
I put a non-existing image to test it out but it displayed the [X] instead of the error message.
Am I doing something wrong?
Anyone know why?
I can't get IE to use onError="alert('Connection error.')" on the <img> tag.
I put a non-existing image to test it out but it displayed the [X] instead of the error message.
Am I doing something wrong?
Anyone know why?
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
The below code worked for me in IE 7
Code:<img src="" onerror="javascript: alert('connection error');" />
Hmm....
Strange.
I'm using
and it doesn't seem to want to work in IE.Code:document.images['imgname'].onerror = function() { alert('Connection Error') }
Stupid IE...
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
Hello...................?
I'm trying to implement it using
Code:document.images['imgname'].setAttribute('onerror','dothis()')
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
That one line of code implies that you are probably either adding the onerror attribute after the page or image tag has loaded/been parsed, in which case the error it is set to detect has already happened before the onerror event is added to the tag, or you are attempting to add the event before the tag to which it will be added has been parsed, in which case it will not be added as the tag doesn't yet exist.
You could add the attribute inline (hard coded) as codeexploiter showed (which is invalid in many DOCTYPES) or add it dynamically as you are doing, but wait until after that to set the src attribute of the image (also dynamically).
You could also add the image tag dynamically with the onerror attribute already a part of it.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Strange. The image is already loaded.
It's working in every other browser except Internet Explorer.
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
Never mind, problem fixed.
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
Bookmarks