0

I am having the following issue in a mobile web application I am developing: In javascript, I have a Image() control and I have an event attached to the image control that should fire when the image gets loaded. Inside of the "pageshow" event for the page, I am setting the src attribute of the Image() to a valid image. If I return to the page, after having visited the page once, the load event for the image is not firing. I have seen several threads say that this can be caused by the image being cached but in my case I am pretty sure that is not the issue. Why doesn't the load event for the image fire and how can I make it work properly?

Code follows:

<script>
var srcImage = new Image();
$(srcImage).on("load", function() {
 ...
});
$(document).one("pageshow", '#pageid', function () {
 srcImage.src = imagepath;
 });
</script>
Obi Wan
  • 889
  • 10
  • 26

1 Answers1

0

I found the issue, thanks to epascarello (see above comments). I assumed the image file was valid but discovered it was not. When a valid image file is used, the above code works fine.

Obi Wan
  • 889
  • 10
  • 26