Tuesday, September 21, 2010

Sore Gums Teeth Extraction

Image prefetch with javascript

In order to Perform image prefetching with javascript we need to create an Image object and insert an url in ITS 'src' global variable, AS FOLLOWS:

var img = new Image ()
img.src = ' http://my_url.jpg '


Then we can attach handlers in order to be Advised When fetching operation completes Or When it goes wrong:

img.onload = function () {
/ / remove placeholder image and show
}

img.onerror = function () {
/ / remove placeholder That image loading and print Went Wrong
}


That's all, enjoy

0 comments:

Post a Comment