2

As per MDN we can use the browser's local storage using the simple-storage module. But when I am trying to include any package in the .js file i get the error saying

JPM undefined   Message: ReferenceError: require is not defined

The sample code for one of my js files is as follows

// Creating the Object for Accessing the local browser storage
var ss = require("sdk/simple-storage");
//Fetching the values in the various fields
var id = document.getElementById("usermail");
var pass = document.getElementById("password");
var login = document.getElementById("login");

//Saving the values for the id and password fields

login.addEventListener("click", function() {
    storage_object.storage.Email = id.value ;
    storage_object.storage.Password = pass.value;
    login_Email = storage_object.storage.Email; 
    login_pass = storage_object.storage.Password;
    alert(login_pass);
});

how to use the browser local storage in the add-on?

OshoParth
  • 1,492
  • 2
  • 20
  • 44
  • 1
    `one of my js files` - is this file a contentScript of some sort perhaps? – Jaromanda X Aug 05 '15 at 12:54
  • The add-on consists of various .js files that are invoked by index.js in relation to the data that needs to be displayed in the panel.This js file is responsible for storing the data entered by the user in browser's local storage. – OshoParth Aug 06 '15 at 04:29
  • all I know is that `require` is not available to all JS code in a firefox addon. When I first read about the new JPM addon SDK I do recall reading about where the nodejs style methods work and where they do not. I can't find that documentation now, but it's definitley there on MDN – Jaromanda X Aug 06 '15 at 05:03

0 Answers0