Well, I thought I was being clever, didn't I? Using WebP images for Machin stamps. Alas, WebP has only recently been supported by Apple's Safari, so the web page didn't work at all on an older model iPad.
My original HTML was simply:
<img id="picture" class="shadow" src="machin.webp" />
And the source image path was accessed from JavaScript via:
document.getElementById("picture").src
The fix from Brett DeWoody is actually quite elegant. Change the HTML to use picture source sets:
<picture class="shadow"><source srcset="machin.webp" type="image/webp" /><img id="picture" src="machin.png" /></picture>
And use the following to interrogate the chosen path after load:
document.getElementById("picture").currentSrc
No comments:
Post a Comment