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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:42:43+00:00 2026-05-30T17:42:43+00:00

I read Google Chrome Extensions Developer’s Guide carefully, it told me to save options

  • 0

I read Google Chrome Extensions Developer’s Guide carefully, it told me to save options in localStorage, but how is content_scripts able to get access to these options?

Sample:

I want to write a script for a couple of domains, and this script should share some options on these domains.

content_scripts:

//Runs on several domains
(function(){
    var option=getOptions();
    //Get options which have been set in options.html
    if(option){
        doSome();
    }
})

option_page:

<html>
    <head>
        <title>My Test Extension Options</title>
    </head>
    <body>
        option: <input id="option" type="text" /><br />
        <input id="save" type="submit" /><br />
        <span id="tips">option saved</span>
        <script type="text/javascript">
            (function(){
                var input=document.getElementById('option');
                var save=document.getElementById('save');
                var tips=document.getElementById('tips');
                input.value=localStorage.option||'';
            // Here localStorage.option is what I want content_scripts to get.
                function hideTips(){
                    tips.style.visibility='hidden';
                }
                function saveHandler(){
                    localStorage.option=input.value||'';
                    tips.style.visibility='visible';
                    setTimeout(hideTips,1000);
                }
                hideTips();
                save.addEventListener('click',saveHandler);
            })();
        </script>
    </body>
</html>
  • 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-30T17:42:44+00:00Added an answer on May 30, 2026 at 5:42 pm

    I would think you could use the chrome.extensions.* API to create a line of communication to a background page that is running under your extension ID, thus giving you local storage.

    I think this is possible because the Content Script docs specify that the chrome.extensions* API’s are available to content scripts. But I have never tried this.

    You would then just have to send messages from the background page to the content script when a connection is made. You could even send one message with all the settings in a literal object.

    Here is an example of creating two way communication I wrote about earlier. You could implement this or create a custom solution but I think this is how you would achieve what you are looking for.

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

Sidebar

Related Questions

I need to be able to read a variable set on a google chrome
I have read and re-read this page, as well as run the samples: http://code.google.com/chrome/extensions/background_pages.html
I google'd a bit and read http://en.wikipedia.org/wiki/Portable_Executable but i can't seem to find when
I already read the datasheet and google but I still don't understand something. In
We have been told that Google Chrome runs each tab in a separate process.
I think I read once that google chrome was working on some kind of
In the Google Chrome developer window, there is a Network tab that shows you
To learn JavaScript I am writing a small text editor Google Chrome extension. But
I am creating a Google chrome extension which can read the contents of clipboard.
I am trying to read clipboard text in Google chrome extension. As of now

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.