Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 676183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:54:00+00:00 2026-05-14T00:54:00+00:00

Short version question : Is there navigator.mozIsLocallyAvailable equivalent function that works on all browsers,

  • 0

Short version question :
Is there navigator.mozIsLocallyAvailable equivalent function that works on all browsers, or an alternative?

Long version 🙂

Hi,
Here is my situation :
I want to implement an HtmlHelper extension for asp.net MVC that handle image post-loading easily (using jQuery).

So i render the page with empty image sources with the source specified in the “alt” attribute.
I insert image sources after the “window.onload” event, and it works great.

I did something like this :

$(window).bind('load', function() {
    var plImages = $(".postLoad");
    plImages.each(function() {
        $(this).attr("src", $(this).attr("alt"));
    });
});

The problem is : After the first loading, post-loaded images are cached. But if the page takes 10 seconds to load, the cached post-loaded images will be displayed after this 10 seconds.

So i think to specify image sources on the “document.ready” event if the image is cached to display them immediatly.

I found this function : navigator.mozIsLocallyAvailable to check if an image is in the cache. Here is what I’ve done with jquery :

//specify cached image sources on dom ready
$(document).ready(function() {
    var plImages = $(".postLoad");
    plImages.each(function() {
        var source = $(this).attr("alt")
        var disponible = navigator.mozIsLocallyAvailable(source, true);
        if (disponible)
            $(this).attr("src", source);
    });
});

//specify uncached image sources after page loading
$(window).bind('load', function() {
        var plImages = $(".postLoad");
        plImages.each(function() {
        if ($(this).attr("src") == "")
            $(this).attr("src", $(this).attr("alt"));
    });
});

It works on Mozilla’s DOM but it doesn’t works on any other one. I tried navigator.isLocallyAvailable : same result.

Is there any alternative?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:54:01+00:00Added an answer on May 14, 2026 at 12:54 am

    after some reseach, I found a solution :

    The idea is to log the cached images, binding a log function on the images ‘load’ event.
    I first thought to store sources in a cookie, but it’s not reliable if the cache is cleared without the cookie. Moreover, it adds one more cookie to HTTP requests…

    Then i met the magic : window.localStorage (details)

    The localStorage attribute provides
    persistent storage areas for domains

    Exactly what i wanted :). This attribute is standardized in HTML5, and it’s already works on nearly all recent browsers (FF, Opera, Safari, IE8, Chrome).

    Here is the code (without handling window.localStorage non-compatible browsers):

    var storage = window.localStorage;
    if (!storage.cachedElements) {
        storage.cachedElements = "";
    }
    
    function logCache(source) {
        if (storage.cachedElements.indexOf(source, 0) < 0) {
            if (storage.cachedElements != "") 
                storage.cachedElements += ";";
            storage.cachedElements += source;
        }
    }
    
    function cached(source) {
        return (storage.cachedElements.indexOf(source, 0) >= 0);
    }
    
    var plImages;
    
    //On DOM Ready
    $(document).ready(function() {
        plImages = $(".postLoad");
    
        //log cached images
        plImages.bind('load', function() {
            logCache($(this).attr("src"));
        });
    
        //display cached images
        plImages.each(function() {
            var source = $(this).attr("alt")
            if (cached(source))
                $(this).attr("src", source);
        });
    });
    
    //After page loading
    $(window).bind('load', function() {
        //display uncached images
        plImages.each(function() {
            if ($(this).attr("src") == "")
                $(this).attr("src", $(this).attr("alt"));
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 363k
  • Answers 363k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try: git --git-dir=/path/to/repo/.git log May 14, 2026 at 3:19 pm
  • Editorial Team
    Editorial Team added an answer The usual method for "tracking any changes" to a table… May 14, 2026 at 3:19 pm
  • Editorial Team
    Editorial Team added an answer It doesn't really matter how you name things as long… May 14, 2026 at 3:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.