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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:03:47+00:00 2026-06-11T20:03:47+00:00

I’m not sure how to do it, and the documentation doesn’t seem to make

  • 0

I’m not sure how to do it, and the documentation doesn’t seem to make this quite obvious.

I tried making a background_page and putting chrome.pageAction.show(tab.id); inside it, but that doesn’t seem to work.

I don’t want to use the browser_action icon because the icon merely reflects the status of the plugin, but it is not a button for performing any actions.

How do I add the page_action’s icon inside the address bar for any page/tab at all times?

EDIT: Here’s my manifest.json:

{
    "name": "My Very First Extension :D",
    "version": "0.0.1",
    "description": "Awesomeness",
    "background_page": "background.html",

    "page_action": {
        "default_icon": "icon.png"
    },

    "content_scripts": [{
        "matches": ["http://*/*", "https://*/*"],
        "js": ["mmm.js"]
    }]
}

Where icon.png is a 19×19 pixel PNG graphic. Here’s the background.html source, where I’m trying to make the page_action icon appear for all tabs:

<!DOCTYPE html>
<html>
    <head>
        <script>
            chrome.pageAction.show(tab.id);
        </script>
    </head>
</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-11T20:03:48+00:00Added an answer on June 11, 2026 at 8:03 pm

    I see two issues with your code.

    1. You cannot use inline script blocks in your background page — js code can only be run from a linked script (like so: <script type="text/javascript" src="background.js"></script>). This is because of the Content Security Policy.

    2. As noted in abraham’s answer, since you want the icon to appear for all pages, you should use browser_action, not page_action. According to Google’s pageAction documentation page:

      Don’t use page actions for features that make sense for most pages.
      Use browser actions instead.

      Icons for page actions appear inside the omnibar (Chrome’s address bar), while icons for browser actions appear as a toolbar button next to the omnibar. Either can be used to reflect the status of the plugin and as an action button.

    Solutions

    To get the icon to appear, you have to call: chrome.pageAction.show(tabId). However, you cannot just call this from a content script, because chrome.pageAction.show() must be passed the tabId, and tabId is retrieved from chrome.tabs, and chrome.tabs is not accessible from content scripts.

    To add a browser action button and define it’s behavior when clicked, define the browser_action element in your manifest.json file …

    "browser_action": {
       "default_title": "action description",
       "default_icon": "icon.png"
    }
    

    … and place this code in your background script:

    // Define behavior when browser action icon is clicked
    chrome.browserAction.onClicked.addListener(function(tab) {
       // executed when the user clicks on the browser action icon
    });
    

    Or, if you want to go against convention and use a pageAction, you can use the manifest.json code from your question and place the following into your background script:

    // Show page action icon in omnibar.
    function showPageAction( tabId, changeInfo, tab ) {
        chrome.pageAction.show(tabId);
    };
    // Call the above function when the url of a tab changes.
    chrome.tabs.onUpdated.addListener(showPageAction);
    

    For further research, check out the source code of some of their sample extensions.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this

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.