Storing files offline in Firefox 3.5 with file:// protocol

While experimenting with the code for offline storage in Firefox 3.5, I referred to a tutorial on . When the page loads, I am prompted with a dialog asking to store data, but after clicking Allow, the dialog does not disappear. The application functions correctly in the online demo provided on the website. Below is the source file that includes the JavaScript:

todo.html

<!--
  Simple task list application used to illustrate Firefox's offline/DOMStorage capabilities

  Author: Mark Finkle
-->

<html manifest="todo.manifest">
  <head>
    <title>TODO - Offline Demo</title>
    <script type="text/javascript" src="json.js"></script>
    <script language="javascript">
    var taskStorage = "[]";
    var storageDomain = location.hostname;
    if (storageDomain == "localhost")
      storageDomain += ".localdomain";

    function loaded() {
      updateOnlineStatus("load", false);
      document.body.addEventListener("offline", function () { updateOnlineStatus("offline", true) }, false);
      document.body.addEventListener("online", function () { updateOnlineStatus("online", true) }, false);

      if (typeof globalStorage != "undefined") {
        var storage = globalStorage[storageDomain];
        if (storage && storage.taskStorage) {
          taskStorage = storage.taskStorage;
        }
      }

      fetchList();
    }

    // Rest of the script omitted as it involves additional lines of JavaScript code...
    </script>

    // Additional stylesheet properties also defined... e.g., body, div#container, div#title, etc.

  </head>
  <body onload="loaded();">
    <div id="container">
      <div id="title">Task Helper - <span id="status">ONLINE</span></div>
      <div id="subtitle">simple online/offline demo application</div>
      <hr />
      <div id="tasklist">
      </div>
      <input type="text" id="data" size="35" />
      <input type="button" value="Add" onclick="addItem();"/>
      <hr />
      <input type="button" value="Remove" onclick="removeItems();"/>
      <input type="button" value="Complete" onclick="completeItems();"/>
      <div id="log"><strong>Event Log</strong>
      </div>
    </div>
  </body>
</html>

Answer №1

It appears that the localStorage api is now taking over for globalStorage in FF 3.5. For more information, you can visit this link: https://developer.mozilla.org/en/DOM/Storage

In my opinion, the api functionalities are quite similar, so you might want to experiment with code like the following:

var storage;
if (typeof localStorage != "undefined") {
    storage = localStorage;
}
else if (typeof globalStorage != "undefined") {
    storage = globalStorage[storageDomain];
}
if (storage && storage.taskStorage) {
    taskStorage = storage.taskStorage;
}

I hope this information proves useful!

UPDATE: If you are currently using globalStorage, don't forget to also check for localStorage. Alternatively, consider moving the storage variable up in scope and detecting it just once.

Answer №2

Upon carefully reviewing the question for the second time, it appears that you are inquiring about the utilization of globalStorage within file:/// documents.

globalStorage (along with localStorage) does not function effectively in file:/// documents in Firefox 3.5 and onwards. While I did not come across a specific bug report regarding this issue, given that globalStorage is being phased out in favor of localStorage, the issue seems somewhat insignificant.

If you are simply experimenting with it, consider setting up a local web server, as it is a straightforward process.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to calculate the duration of a .wav file stored locally using JavaScript?

Can you help me figure out how to determine the duration (in milliseconds) of a .wav file using JavaScript for a GreaseMonkey Script? The main challenges I'm encountering are: 1) Accessing local files 2) Retrieving the length of the wav file ...

Tips for overlapping children in a column flex direction while maintaining the parents' positioning

Currently, I am working with two parent flex items, arranged with flex-direction: column. Within the first parent, there are two children. However, one of the children is optional and may be removed at times. I aim to have the optional child displayed on ...

Leveraging JQueryUI for an audio Seek feature, and dynamically connecting a fresh slider to the <audio> element whenever a song is swapped out

Thanks for taking a look at my question. The code snippet can be found HERE. I'm in the process of creating an audio player to handle multiple songs on a single page using JQueryUI Slider and HTML5 Audio, with one Audio element and several sliders. ...

Using jQuery to select the child element of the parent that came before

Recently, I've been experimenting with creating animations using CSS and jQuery. While it has been successful so far, I'm now looking to take it a step further. Specifically, I want information to appear on top of an image when the user clicks on ...

NodeJS - session information lost after building ReactJavaScript application

I've created a NodeJS web application with basic functionality for user login and pulling data from MySql based on session information. The app is functioning as intended (Link). However, when I implement the client-side in React, the session data is ...

Google Scripts: Generating a set of data to include in an email

As a newcomer to Google Script and JavaScript, I'm on a mission to email a list of file names extracted from a spreadsheet. The names reside in a column within my sheet, and after defining a variable called "newfiles" to cherry-pick only the necessary ...

The integration of <form> with jQuery Ajax error

I have come across this HTML form function FormSubmit (){ $.ajax({ url:'dotar.php', type:'post', data:$('form').serialize(), success:function(){ setTi ...

Tips for including arguments in pm2 file execution

What steps should I take to run the cluster.js file on pm2 successfully? When I try executing the file locally with 'node cluster.js 0 1' command, it appends two arguments but encountering an error when using 'pm2 start "cluster.js 0 1"&apos ...

Initialization of an empty array in Typescript

My promises array is structured as follows: export type PromisesArray = [ Promise<IApplicant> | null, Promise<ICampaign | ICampaignLight> | null, Promise<IApplication[]> | null, Promise<IComment[]> | null, Promise<{ st ...

Is Jade used for making subsequent lines children of an included partial?

Recently, I've encountered an issue with a basic jade layout. Here is an example: include test.jade #bar hi In the test.jade file: #foo hello No matter what I try, the #bar element always ends up as a child of #foo. <div id="foo">hello &l ...

Resizing Div elements in React

I am currently working on a Drawer navigation feature and I am exploring the option of enabling mouse drag resize functionality. To achieve this, I have included a div element where I listen for the onMouseDown event. Once triggered, I then add an event li ...

Retrieve the file from Amazon S3 and download it

I'm having an issue with downloading a file from a directory outside of the root. Whenever I try, it defaults to looking in the root directory. I need users to be able to download these files on my site. The file was initially uploaded to Amazon S3 a ...

What is the best way to save a token value to a JavaScript file on my local storage

Hello, I am new to Nodejs and have implemented passportjs token-based authentication. When a user logs in, a token is provided for each user. Now, I want to perform certain operations based on the users who have token values. For example, if a user wants t ...

Transitioning the height of a Vue component when switching routes

I've been struggling to implement a transition slide effect on my hero section. The height of the hero is set to 100vh on the homepage and half of that on other pages. Despite trying various methods, I haven't been able to get it working properly ...

Check if a user is currently on the identical URL using PHP and JavaScript

In my Laravel and AngularJS project, I have a functionality where users can view and edit a report. I'm looking to add a feature that will prevent multiple users from editing the report at the same time - essentially locking it while one user is makin ...

The error message "UnhandledPromiseRejectionWarning: Error: ENOTEMPTY: directory not empty" typically occurs

Struggling to successfully run the build using npm run build. Encountering the following error: UnhandledPromiseRejectionWarning: Error: ENOTEMPTY: directory not empty, rmdir '/var/www/html/abhinav/png-react/png-compressor/build/static' ...

Using TypeScript to define values with the placeholder "%s" while inputting an object as a parameter

One common way to decorate strings is by using placeholders: let name = "Bob"; console.log("Hello, %s.", name) // => Outputs: "Hello, Bob." I'm curious if there's a way to access specific values within an object being passed in without specif ...

Is it possible to view the CSS of a PDF file in print template mode using Chrome?

https://i.stack.imgur.com/XlcWm.png Currently facing an issue with debugging CSS on my PDF template. I am unable to inspect the styles directly in the CSS due to limitations. When using inspect element in Chrome, only the styles for text and elements are ...

Showing a gallery of images in React

I have a unique situation where I am working on setting a variable to match the import statement that calls for images. Once I have this variable assigned, I want to use it to display the corresponding image. For instance, if my code generates the name &ap ...

Tally each div individually and display the count within each div, instead of showing the total count across

I have come across various solutions that show the total number of certain special divs, such as: $('.someclass').length However, I am facing a different challenge. I want to sequentially count each div with a numerical sequence. For instance, ...