Re: Issue 7731 in chromium: Image onload event does not fire when loading an already loaded image.

528 views
Skip to first unread message

chro...@googlecode.com

unread,
Jul 10, 2010, 12:41:39 AM7/10/10
to chromi...@chromium.org

Comment #10 on issue 7731 by dane514: Image onload event does not fire when
loading an already loaded image.
http://code.google.com/p/chromium/issues/detail?id=7731

This is not technically a bug. WebKit is just more strict. You must
instantiate a new Image() object before the replacement, like this:

var photo = document.getElementById('image_id');
var img = new Image();
img.addEventListener('load', myFunction, false);
img.src = 'http://newimgsource.jpg';
photo.src = img.src;

This is how it to properly do it for all browsers.

chro...@googlecode.com

unread,
Jul 10, 2010, 12:45:40 AM7/10/10
to chromi...@chromium.org

Comment #11 on issue 7731 by dane514: Image onload event does not fire when

chro...@googlecode.com

unread,
Jul 10, 2010, 12:49:41 AM7/10/10
to chromi...@chromium.org

Comment #12 on issue 7731 by dane514: Image onload event does not fire when

This is not a bug. WebKit is just more strict. You must instantiate a new

chro...@googlecode.com

unread,
Oct 10, 2010, 6:56:22 AM10/10/10
to chromi...@chromium.org

Comment #13 on issue 7731 by drinking...@abv.bg: Image onload event does
not fire when loading an already loaded image.
http://code.google.com/p/chromium/issues/detail?id=7731

None of the solutions above fixed my problem..
i Have a dynamic background image that is changing on clicking different
input buttons
and an onload event (javascript)
the image is generated using PHP and sometimes it is working fine, other
times it flickers :(
i cannot identify when this is happening but on IE5 it is working fine.


chro...@googlecode.com

unread,
Oct 31, 2012, 4:36:07 PM10/31/12
to chromi...@chromium.org

Comment #14 on issue 7731 by Nathanae...@gmail.com: Image onload event does
not fire when loading an already loaded image.
http://code.google.com/p/chromium/issues/detail?id=7731

How is this not a bug exactly? The html spec requires that the 'onload'
even be fired even for cached and previously accessed URLs.

http://www.w3.org/TR/html5/the-img-element.html#the-img-element

It's a bug.

chro...@googlecode.com

unread,
Oct 31, 2012, 5:02:07 PM10/31/12
to chromi...@chromium.org
Updates:
Cc: jry...@chromium.org

Comment #15 on issue 7731 by jry...@chromium.org: Image onload event does
not fire when loading an already loaded image.
http://code.google.com/p/chromium/issues/detail?id=7731

Issue 104954 has been merged into this issue.

chro...@googlecode.com

unread,
Jun 17, 2014, 9:52:26 AM6/17/14
to chromi...@chromium.org

Comment #18 on issue 7731 by apfelbe...@googlemail.com: Image onload event
does not fire when loading an already loaded image.
http://code.google.com/p/chromium/issues/detail?id=7731

If you run code with "image.onload" from localhost (example:
http://localhost:8383/image-test/index.html then the "onload" is fired
multiple times. I uploaded my test page then to github.io and there is
onload event was only triggered once (when setting the "src" path to the
same one). The trick with setting "src" to an empty string and then assign
the same URL again fixes the problem but it also causes image flickering
(when changing to an empty string and changing back).

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

chro...@googlecode.com

unread,
Nov 17, 2014, 3:30:44 AM11/17/14
to chromi...@chromium.org
Updates:
Cc: y...@yoav.ws

Comment #21 on issue 7731 by zcor...@gmail.com: Image onload event does not
fire when loading an already loaded image.
https://code.google.com/p/chromium/issues/detail?id=7731

From what I understand of the description of this bug, I can reduce it to:

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3306

This passes for me, as does the test case in comment 3.

However, if I set src to the same value directly, I don't get a second load
event.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3304 (This is
what duplicate bug 104954 does.)

There is a test case for this in
http://w3c-test.org/html/semantics/embedded-content/the-img-element/relevant-mutations.html
but it passes! It turns out that Blink fires the load event if there is
another img element with the same src with the crossorigin attribute
present.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3305

chro...@googlecode.com

unread,
Nov 17, 2014, 3:34:28 AM11/17/14
to chromi...@chromium.org
Issue 7731: Image onload event does not fire when loading an already loaded
image.
https://code.google.com/p/chromium/issues/detail?id=7731

This issue is now blocking issue chromium:418903.
See https://code.google.com/p/chromium/issues/detail?id=418903

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

chro...@googlecode.com

unread,
Sep 20, 2015, 9:20:08 PM9/20/15
to chromi...@chromium.org

Comment #27 on issue 7731 by grummbun...@gmail.com: Image onload event does
not fire when loading an already loaded image.
https://code.google.com/p/chromium/issues/detail?id=7731

function internetstart()
{
//window.addEventListener("load", draw, true);
var canvas = document.getElementById('showimg');
var context = canvas.getContext('2d');

var img1 = new Image();
var img2 = new Image();
canvas.width = 800;
canvas.height = 780;
if(imgctr < 1){ imgctr=imgmax; }
if(imgctr > imgmax){ imgctr=1; }

img1.src = '';
img2.src = '';
img1.src = 'bf' + imgctr + '.jpg';
img2.src = 'bf.png';

document.getElementById('bfafnum').textContent = imgctr + '/' + imgmax;
document.getElementById('bfaf').textContent = "Before";

img1.onload = function() {
img2.onload = function() {
context.drawImage(img1, 0, 0, 800, 780);
context.drawImage(img2, 0, 0, 800, 780);
}
}
//context.drawImage(img1, 0, 0, 800, 780);
//context.drawImage(img2, 0, 0, 800, 780);
}


nested unnested, the commented makes it work better. problem is the size of
image bigger more often will not show image. the problem is not constant,
but it is frequent, i think there should be a way to ask if it actually did
load the img. this onload does not ask if it loaded, or it would show the
image. i have tested this on tablet and pc, ps yes unnested is the taught
way, assume i have done it un nested because i have. i suppose i should
mention the variables for the image number are var global. i do not feel
this is solved at all. i have several pages i put up with this. not only
mine too.


--

chro...@googlecode.com

unread,
Sep 20, 2015, 9:22:29 PM9/20/15
to chromi...@chromium.org

Comment #28 on issue 7731 by grummbun...@gmail.com: Image onload event does
not fire when loading an already loaded image.
https://code.google.com/p/chromium/issues/detail?id=7731

ps it isnt chromes fault, i see no browser works it at all. very erratic

chro...@googlecode.com

unread,
Jan 4, 2016, 5:04:45 AM1/4/16
to chromi...@chromium.org

Comment #29 on issue 7731 by Rudolfs....@gmail.com: Image onload event does
not fire when loading an already loaded image.
https://code.google.com/p/chromium/issues/detail?id=7731

This is a serious issue with multipart/x-mixed-replace images - the load
event is fired only for the first image, and thus there is no way to
monitor if the image stream is still working or not. Any hope this will be
fixed? Firefox on the other hand fires the even on each new load.
Reply all
Reply to author
Forward
0 new messages