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

  • Home
  • SEARCH
  • 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 8918375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:44:13+00:00 2026-06-15T05:44:13+00:00

This is my popup.js in the chrome extension: function getlink(){ console.log(document.getElementById(linkify).value); if(document.getElementById(linkify).value == on)

  • 0

This is my popup.js in the chrome extension:

 function getlink(){

    console.log(document.getElementById("linkify").value);
    if(document.getElementById("linkify").value == "on")
    {
            localStorage.setItem("linkify",false);

            document.getElementById("linkify").innerHTML = "Get links - off";
            document.getElementById("linkify").value = "off";
            console.log(document.getElementById("linkify").value);
            chrome.extension.sendRequest({ msg: "linkify"});

    }
    else if(document.getElementById("linkify").value == "off")
    {
        localStorage.setItem("linkify",true);
        console.log("Hello!");
        document.getElementById("linkify").innerHTML = "Get links - on";
        document.getElementById("linkify").value = "on";
        chrome.extension.sendRequest({ msg: "linkify"});

    }
    }

    $(document).ready(function (){


    if(localStorage.getItem("linkify"))
    {
        document.getElementById("linkify").innerHTML = "Get links - on";
        document.getElementById("linkify").value = "on";
    }
    $("#linkify").click(function() {
      getlink();
    });
    });

Basically, the functionality that I want is this: a button in the extension which can be toggled on or off. When toggled, its text changes and so does the value stored in localStorage.

Though, the toggle works fine, this is the bug that happens:

If I switch off the button, that is turn it into get links off and exit the popup. And then open the popup again, the button state is back “on”. It is not maintaining its state.

  • 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-15T05:44:14+00:00Added an answer on June 15, 2026 at 5:44 am

    You problem is how you are using local storage. Local storage stores everything as a string.

    So basically:

    localStorage.setItem("foo", false)
    localStorage.getItem("foo") // returns "false"
    
    if(localStorage.getItem("foo")) {
      console.log("bar")
    } else {
      console.log("bing")
    }
    // Logs bar
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I included some adsense code in my google chrome extension popup file. Unfortunately this
In background.html of my chrome extension I have: $(document).ready(function(){ var some_variable = some_variable; function
Message passing: chrome.extension.onConnect.addListener(function(port) { console.assert(port.name == knockknock); port.onMessage.addListener(function(msg) { if (msg.joke == Knock knock)
I am trying to open a popup like this: $('#btn').click(function () { var popup
This issue drove me nuts for 2 days. I made a simple chrome extension
I've got a chrome extension with a popup.html and an injected content script. With
I'm creating a Disqus notifier Chrome extension. This involves making an HTTP call to
I want to modify the popup.html of the chrome extension. I load an iFrame
I am exceuting this AJAX request in a google chrome extension; which logs an
Could someone shed some light on where this code is incorrect please <script> chrome.browserAction.onClicked.addListener(function(window)

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.