javascript - image.onload not firing twice in IE7 -


It works in IE 6 and Firefox; But not in IE7 for some reasons.

Using ASP.NET on Page_Init, I populate a list of chapters which contain a link to the image in the book along with the JavaScript array that holds the page ID.

ex.

Chapter 1 -> href = "javascript: seePage (4);"

Here is the real code I am using:

  var availablePages = ['1002_001', '1002_002', '1002_003', '1002_004', '1002_005 ']; View function page (index) {$ get ('imgSingle'). Src = 'graphics / loading.gif'; Var img = new image (); Img.src = 'get.jpg.aspx? Size = single and id = 'available page [index]; Img.onload = function () {var single = $ mill ('imgSingle'); Single src = img.src; }}  

When I click on Chapter 1, the image load is fine in the entire board (IE 6,7, FF) and clicking on the second chapter link also works is; However, (and only) clicked twice on the same chapter in IE7 (chap1, chap2, then chap1 again) the image gets trapped on the 'loading' image ... I am pulling my hair here. .

This is because IE will cache the image, and the online event will be pre-existing Will never be cracked after loaded.

You need to set the status of the load event before src.

  var available page = ['1002_001', '1002_002', '1002_003', '1002_004', '1002_005']; View function page (index) {$ get ('imgSingle'). Src = 'graphics / loading.gif'; Var img = new image (); Img.onload = function () {var single = $ mill ('imgSingle'); Single src = img.src; } Img.src = 'get.jpg.aspx? Size = single & amp; Id = 'available page [index]; }  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -