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

The Archive Base Latest Questions

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

What am I doing wrong? I want to run a function when clicking Show

  • 0

What am I doing wrong? I want to run a function when clicking “Show me some foo”.

manifest.json browser_action

"browser_action": {
"default_icon": "img/icon.png",
"default_popup": "popup.html"
  },

popup.html

<!DOCTYPE html>
<html>
  <head>
  <meta charset="UTF-8">
    <script type="text/javascript" src="js/popup.js"></script>
  </head>
  <body>
 <div class="changes">

<span class="reset"><a href="#" title="Get some foo!" id="foo">Show me some foo</a>
</span>
</div>
  </body>
</html>

popup.js

chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.tabs.executeScript(null,
                       {file:"reset.js"});
});

reset.js

var el = document.getElementById('foo');
el.onclick = showFoo;


function showFoo() {
  alert('I am foo!');
  return false;
}

Full manifest.json file

{
  "name": "App name",
  "version": "1.0.2",
  "manifest_version": 2,
  "description": "Desc.",
  "permissions": [
    "tabs"
  ],
  "browser_action": {
    "default_icon": "img/icon.png"
  },
  "background": {
    "page": "background.html"
  },
  "browser_action": {
    "default_icon": "img/icon.png",
    "default_popup": "popup.html"
  },
    "content_scripts": [
    {
      "matches": [
    "http://*/*",
    "https://*/*"
],
  "js": ["js/myscript.js"],
  "exclude_matches":[
    "http://site.com/*"
]
}
  ],
  "web_accessible_resources": [
"chrome_ex_oauth.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-06-13T13:00:45+00:00Added an answer on June 13, 2026 at 1:00 pm

    I’m not sure what you are trying to do, but I’ll explain your code to you:

    • user clicks a browserAction
    • popup window is crated and scripts from popup.html are loaded
    • popup.js loads and registers a listener chrome.browserAction.onClicked.addListener
    • user closes a popup window (by clicking anywhere outside it or on the browserAction again)
    • pupup.html page is unloaded
    • chrome.browserAction.onClicked.addListener listener is unregistered

    As you can see reset.js is never loaded as it’s never injected. What’s more, you can’t have a popup.html and chrome.browserAction.onClicked.addListener in the same extension (“This event will not fire if the browser action has a popup.” source).

    You probably want to put chrome.browserAction.onClicked.addListener into the background page so that reset.js is injected to current page whenever browserAction is clicked. And, as I mentioned above, for chrome.browserAction.onClicked.addListener to fire, you need to get rid of "default_popup": "popup.html" from manifest.

    If you wanted to inject a script to popup.html – it doesn’t make much sense. You have full control over popup.html and you can simply put reset.js in the <head>.

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

Sidebar

Related Questions

I must be doing something wrong here. I want to a function to run
I'm trying to run a function in a task but I'm doing something wrong.
What am I doing wrong? I have a CheckBoxList and I want to handle
so I don't understand what I am doing wrong here. I want to populate
Total newbie question, but I cant figure out what im doing wrong. I want
Ran into something interesting, want to know if I'm doing something wrong or if
I really don't know what i'm doing wrong. I want to count the rows
I have a popup window and I want to run a function from in
I want to run function insertHouse() when dropping div#Draggable. I can't manage to make
what am I doing wrong in this code.. I should get the class name

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.