R
Ross
I have an application that uses an image which is occasionally loaded
and popped up to the top layer for a couple of seconds, then hidden
again. We don't know what the image will be until it arrives from a
distant server.
Everything was working fine, until I recently noticed that if I
receive an image to show which is the same as the previous one (which
should happen sometimes), it doesn't show up on Safari.
This is working fine on Firefox:
myImage.onload = function() {
picIsUp = true; //set this flag AFTER img
is loaded
}
myImage.setAttribute('src', (aImgName));
In Firefox the picIsUp flag raises as it should every time I get the
image.
However, on Safari, the image loads the first time, but never again.
I speculated that it was not firing onload if the src image attribute
was being set to the same image as the existing one. So after hiding
the myImage behind the top-layer, on expiry of the display period,I
tried to set the src attribute to a blank image, and sure enough now
it fires every time in Safari.
Is there some other way to ensure Safari fires onload each time I set
that src attribute, without using the blank image setting? Loading
the blank image seems to make my web app stall for 1 or 2 seconds
which is a bit ugly. I'm hoping there's some more obvious way.
I could check to see if the new img is the same as the old img but
that seems even more kludgey and would have me storing previous
states.
Thanks in advance for any suggestions,
Ross.
and popped up to the top layer for a couple of seconds, then hidden
again. We don't know what the image will be until it arrives from a
distant server.
Everything was working fine, until I recently noticed that if I
receive an image to show which is the same as the previous one (which
should happen sometimes), it doesn't show up on Safari.
This is working fine on Firefox:
myImage.onload = function() {
picIsUp = true; //set this flag AFTER img
is loaded
}
myImage.setAttribute('src', (aImgName));
In Firefox the picIsUp flag raises as it should every time I get the
image.
However, on Safari, the image loads the first time, but never again.
I speculated that it was not firing onload if the src image attribute
was being set to the same image as the existing one. So after hiding
the myImage behind the top-layer, on expiry of the display period,I
tried to set the src attribute to a blank image, and sure enough now
it fires every time in Safari.
Is there some other way to ensure Safari fires onload each time I set
that src attribute, without using the blank image setting? Loading
the blank image seems to make my web app stall for 1 or 2 seconds
which is a bit ugly. I'm hoping there's some more obvious way.
I could check to see if the new img is the same as the old img but
that seems even more kludgey and would have me storing previous
states.
Thanks in advance for any suggestions,
Ross.