Open main menu

CDOT Wiki β

Changes

DPS909/OSD600 Fall 2017 Lab 11

198 bytes added, 12:38, 13 December 2017
Step 1. Write a Test Case
<pre>
When I use Safari on my MacWith some browsers, I notice that <img> elements in my page don't seem to always have fire their onload event fire. Specifically, when I set the .src of an image to the same URL as it's already using, no load event fires. My code looks something like this:
var img = document.querySelector('#image-1234');
img.src = "http://some.url.com/image";
 
...
// Some where late in the code I set the URL to the same thing again
img.src = "http://some.url.com/image";
 
// I'd expect the onload event to fire a second time, but it doesn't always in this case!
Later on, I sometimes need to reset the image, and in some cases, it needs to use the same URL again. I expect to get an onload event firing every time I change the img.src, no matter what the URL is.