<script>
var imgSrc = 'https://discussions.apple.com/public/assets/avatars/SYSTEM_DEFAULT_AVATAR_EN_8999.png'
var my_image2 = new Image();
// notify the user that the image has been preloaded, and reveal the
// button to use the preloaded image
function notify() {
console.log('notify')
document.getElementById('preloadbutton2').style.display = 'none';
document.getElementById('after_preload').style.display = 'block';
}
function preload() {
my_image2.onload = notify;
my_image2.src = imgSrc;
}
// using only the file name, we can take advantage of the preloaded image
function use_preloaded_image() {
document.getElementById('saturnplaceholder').src = imgSrc;
}
</script>
<input type="button"
id="preloadbutton2"
value="Preload Image"
onclick="preload();this.value='Loading. Please wait...'" />
<div id="after_preload" style="display: none">
<input type="button" value="Use Preloaded Image"
onclick="use_preloaded_image()" /><br />
<img src="blank.jpg" id="saturnplaceholder" width="500" />
</div>
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.