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 8966057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:56:35+00:00 2026-06-15T16:56:35+00:00

I have this in my background.js: var write = function (line) { if (localStorage[silent]

  • 0

I have this in my background.js:

var write = function (line) {
  if (localStorage["silent"] == true) {
    chrome.extension.getBackgroundPage().console.log(line);
  } else {
    alert(line);
  }
}
var getFromStorage = function (item, default) {
  if (localStorage[item] == undefined) {
    write("Could not find " + item + " in local storage...");
    return default;
  } else {
    return localStorage[item];
  }
}

var isOn = getFromStorage("isOn", true);
var silent = getFromStorage("silent", false);

And this in my popup.js:

var bgPage = chrome.extension.getBackgroundPage();
var isOn = bgPage.getFromStorage("isOn", true);
var silent = bgPage.getFromStorage("silent", false);

And I get this error:

Object [object Window] has no method 'getFromStorage'

Help is greatly appreciated, thanks 🙂

  • 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-06-15T16:56:37+00:00Added an answer on June 15, 2026 at 4:56 pm

    You should change the default parameter in your background script

      var write = function (line) {
        if (localStorage["silent"] == true) {
          chrome.extension.getBackgroundPage().console.log(line);
        } else {
          alert(line);
        }
      }
      var getFromStorage = function (item, d) {
        if (localStorage[item] == undefined) {
          write("Could not find " + item + " in local storage...");
          return d;
        } else {
          return localStorage[item];
        }
      }
    
      var isOn = getFromStorage("isOn", true);
      var silent = getFromStorage("silent", false);
    

    Because default is reserved in javascript. (It is used in conjunction with the Switch statement)
    Therefore the background page wouldn’t load at all and Inspecting it should result in something like this Uncaught SyntaxError: Unexpected token default at background.js:8

    Which then leads to the error Object [object Window] has no method 'getFromStorage'
    in your popup script, because getFromStorage actually never has been loaded in your background script because of terminating at Line 8

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code snippet: $(function() { $('.toolbar [id^=button]').on('click', function () { $(this) .css('background-color',
I have this in my CSS file: body {style.css (line 3) background:#CDF8FF url(images/final_bg.jpg) no-repeat
So I have the following code: $(document).on('click', 'a[data-link]', function () { var $this =
I have this background image that is 175x175 but I am trying to make
I have this background, the css code is: body { background: #FFF url('images/bg.png') no-repeat
Background: I have this with rollup query defined in MySQL: SELECT case TRIM(company) when
I have this CSS. the property FILTER In class .crumb make my background and
I have this query which works correctly in MySQL. More background on it here
i have this css code, and i want to shorten it. #one{ background: #6cab26;
let's say I have this set of HTML-markup and CSS #CSS .inputhelp_text { background:

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.