str11
str11

Reputation: 437

Pre-Load Custom Cursors With Javascript

I have been able to successfully preload image gallery before page loads but was wondering how I could do the same for custom cursor.cur files as it doesn't work using the image method below as it cant understand .cur extension?

// Image Preloader
var pictures [
    "a.jpg",
    ..
    "z.jpg"
];

for (var i=0;i < pictures.length; i++){
    var img = new Image()
    img.src = pictures[i];
    img.onload = function(){
        updateProgress();
    }
}

Upvotes: 5

Views: 827

Answers (1)

leepowers
leepowers

Reputation: 38318

Load the ico file using an AJAX .get() and ignore the response. The response should be cached in the browser. Something like:

    $.get('/favicon.ico', function() {
        alert('Loading of ICO file completed!');
        // Do other processing here
    });  

http://jsfiddle.net/BGG2m/

Upvotes: 4

Related Questions