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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:15:24+00:00 2026-06-12T11:15:24+00:00

I am trying to write a very simple Chrome extension. All it is at

  • 0

I am trying to write a very simple Chrome extension. All it is at this point is a popup html file that tries to display an alert when the browser action icon is clicked. I am obviously doing something wrong because the alert doesn’t fire.

manifest.json

{
  "name": "Simple",
  "description": "Simple",
  "version": "1.0",
  "browser_action": {
    "default_title": "Simple",
    "default_icon": "images/icon.png",
    "default_popup": "popup.html"
  },
  "manifest_version": 2
}

popup.html

<html>
<head>
    <script>
        //Executed when the extension's icon is clicked
        chrome.browserAction.onClicked.addListener(function(tab) 
        { 
            alert("gah");
        });
    </script>
</head>

<body>
    Hello World!
</body>
</html>

I have also tried:

<html>
<head>
    <script>

        function onPageLoad()
        {
            //Executed when the extension's icon is clicked
            chrome.browserAction.onClicked.addListener(function(tab) 
            { 
                alert("gah");
            });
        }

    </script>
</head>

<body onload="onPageLoad()">
    Hello World!
</body>
</html>

UPDATE BASED UPON RESPONSES
Thank you for your response. I’ve made the following changes but is still not being called browser.Action.onClicked() (you can see that instead of an alert I am using console.log(). (The log at global scope is displayed, the one inside the callback is not).

manifest.json

{
  "name": "Simple",
  "description": "Simple",
  "version": "1.0",
  "permissions": ["tabs", "http://*/*", "https://*/*"],
  "background": {
    "persistent": false,
    "scripts": ["popup.js"]
  }, 
  "browser_action": {
    "default_title": "Simple",
    "default_icon": "images/icon.png",
    "default_popup": "popup.html"
  },
  "manifest_version": 2
}

popup.html

<html>
<head>
    <script type="text/javascript" src="popup.js"></script>
</head>

<body>
    <div style="white-space: nowrap">
        Hello World!
    </div>
</body>
</html>

popup.js

console.log("Running at global scope")

//Executed when the extension's icon is clicked
chrome.browserAction.onClicked.addListener(function(tab) 
{ 
    console.log("Running insode of addListener()");
});
  • 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-12T11:15:25+00:00Added an answer on June 12, 2026 at 11:15 am

    chrome.browserAction.onClicked can’t be used inside a popup. It doesn’t make much sense – you start listening for browser action icon being clicked after it was already clicked. It can be clicked again, but then popup will be closed and listener will be terminated before anything happens.
    chrome.browserAction.onClicked is supposed to be used on the background page and only when popup for browser action is not used:

    This event will not fire if the browser action has a popup.

    source

    You should probably just write:

    <script>
            alert("gah");
    </script>
    

    But I’m not sure if alerts work in a popup. Better try something like:

    <script>
            document.getElementsByTagName('body')[0].innerHTML = "gah";
    </script>
    

    EDIT

    There is one more thing to fix in your extension. As @Cody suggested in his answer, you shouldn’t have used inline script. It is blocked for security reasons. Take the code I suggested above and put it into a separate javascript file, then include it in popup.html head:

    <script src='script.js' type='text/javascript'></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a very simple regular expression that matches any file name
I am trying to write a very simple RSS channel which would display the
I am currently trying to write a very simple app that sends an object
I'm trying to write a very simple Python utility for personal use that counts
I'm trying to write a very simple terminal app that will scan for Bluetooth
I am trying to write a very simple Android application that checks the signal
I'm trying to write a very simple plugin that on anchor mouseover increases the
I'm trying to write a very simple app that will do just one very
I'm trying to write a very simple program in C++ that finds the modulus
I am trying to write a very simple slide up and slide function that

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.