jodleren said:
I am updating a system, and want to check this line:
document.all.preview.src = 'Temp/' + ob.id +'.bmp';
Don't; that's proprietary IE/MSHTM nonsense. Should be
document.images["preview"].src = 'Temp/' + ob.id +'.png';
(The `img' element should have the name `preview', although ID `preview'
is supported by standards-compliant browsers, too.)
As a nice side effect, it is going to work outside of Windows and Internet
Explorer regardless of layout mode.
by added
if not loaded then
document.all.preview.src = something else;
How do I check whether the picture loaded?
Try this quickhack (untested; partially proprietary too, but that part
should work everywhere where client-side scripting is supported, for
historical reasons):
/*
* Helper functions; see <
http://PointedEars.de/scripts/dhtml.js>
* for the fully featured versions
*/
function _addEventListener(o, sEvent, fListener)
{
if (!o || !sEvent || !fListener) return;
/* see isMethod() for a more precise feature test */
if (typeof o.addEventListener == "function")
{
/* W3C DOM Level 2, 3-WD Events compliant */
o.addEventListener(sEvent, fListener, false);
}
else
{
/* proprietary: IE/MSHTML a.o. */
o["on" + sEvent.toLowerCase()] = fListener;
}
}
function _removeEventListener(o, sEvent, fListener)
{
if (!o || !sEvent || !fListener) return;
/* see isMethod() for a more precise feature test */
if (typeof o.removeEventListener == "function")
{
/* W3C DOM Level 2, 3-WD Events compliant */
o.removeEventListener(sEvent, fListener, false);
}
else
{
/* proprietary: IE/MSHTML a.o. */
o["on" + sEvent.toLowerCase()] = null;
}
}
/* End of helper functions */
var img = document.images["preview"];
if (img)
{
var f =
_addEventListener(img, "error",
function() {
/* Don't error out if the replacement image doesn't load */
_removeEventListener(this, "error", arguments.callee);
this.src = "...";
});
img.src = 'Temp/' + ob.id + '.png';
}
else
{
/* DEBUG */
}
Please read the FAQ before posting here: <
http://jibbering.com/faq/#posting>
PointedEars