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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:28:51+00:00 2026-05-24T10:28:51+00:00

I am newbie as far as developing chrome extension is concerned. I am testing

  • 0

I am newbie as far as developing chrome extension is concerned.

I am testing an extension. In this i have a background page and options page. In options page i am storing user entered password in local storage which i want to retrieve in the background page that is on click of browser icon.

My options page is :

<html>
<head>
<title>Options for Password</title>
<script>
 function savePassword()
  {
 window.localStorage.setItem('password', txtPassword.value);


  }
</script>   
</head>
<body >
<h1>Enter Password</h1>
<input type='password' name='txtPassword' id='txtPassword'/>
<br />
<button onclick='savePassword();'>Save</button>
<br />
</body>
</html>

And my background page is:

<html>
<head>
<script>
 // Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {code:"alert('password from tab:'+window.localStorage.getItem('password'));getfeedback_dialog_submitButton.setAttribute('onclick', 'if(gettext.value==\'"+window.localStorage.getItem(password)'+"\'){document.body.removeChild(getfeedbackcontainer);document.body.removeChild(getfeedbackoverlay);}');"});
});


</script>
</head>
</html>

When i save password through options page and then i click on browser action then i am getting the alert password from tab:null.

I am confused how to retrieve the value stored in the local storage?

  • 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-24T10:28:52+00:00Added an answer on May 24, 2026 at 10:28 am

    Your code gets the localStorage value from the page where the browser action is clicked, where it is null. Change your quotes to get it at the background page:

    chrome.tabs.executeScript(null, {code:"alert('password from tab:"+window.localStorage.getItem('password')+"');"});
    

    Note that this may allow for code injection.

    EDIT: Do this, it should work as long as your variables are defined properly and window.localStorage.getItem('password') is expected to be a string:

    chrome.tabs.executeScript(null, {code:"alert('password from tab:"+window.localStorage.getItem('password')+"');"
    +"getfeedback_dialog_submitButton.addEventListener('click', function(event){if(gettext.value=='"+window.localStorage.getItem('password')+"')"
    +"{document.body.removeChild(getfeedbackcontainer);document.body.removeChild(getfeedbackoverlay);}},false);"});
    

    I split your code into multiple lines for readability.

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

Sidebar

Related Questions

I am a newbie as far as open-source development is concerned. I have tried
I am a newbie to Java Web Application development. So far all I have
Thanks to everyone out there helping newbies like me. So far I have this:
I'm a complete newbie as far as jQuery is concerned. I also don't know
I'm an absolute newbie to Moose and so far I have read Moose and
Total newbie to R here (so far very pleased!). I have a large array(vector?)
I have the following form in a html5 document.I am a newbie as far
I am a newbie android developer and so far have only got Hello World
I'm a newbie as far as Java UI development is concerned. I was initially
I'm a newbie to rails and am having some difficulty... I have a page

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.