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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:02:29+00:00 2026-06-14T23:02:29+00:00

Is it possible to change button background color on page load event but so

  • 0

Is it possible to change button background color on page load event but so far I did not find any such method at all. If it is not possible then I am happy to use some pre-defined images that loads up after page load.

I have tried the following, without success:

script.js

// chrome.browserAction.setIcon("red.png");
chrome.browserAction.setIcon({path:'red.png'});

manifest.json

{
  "name": "Domain Colors",
  "version": "1.0",
  "manifest_version": 2,
  "content_scripts": [{
      "matches": ["http://*/*"],
      "js": ["script.js"]
  }],
  "permissions": [ "tabs", "http://*/*" ],
  "browser_action": {
    "default_title": "Colry",
    "default_icon": "blue.png"
  }
}
  • 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-14T23:02:30+00:00Added an answer on June 14, 2026 at 11:02 pm

    In order to use the browserAction API, a background page is required. If you want to keep your current control flow (update icon via a content script), you need to pass messages. Here’s the bare minimum:

    // script.js
    chrome.extension.sendMessage('');
    // background.js
    chrome.extension.onMessage.addListener(function(message, sender) {
        chrome.browserAction.setBadgeBackgroundColor({
            color: 'red',
            tabId: sender.tab.id
        });
    });
    

    The manifest file needs one additional entry:

    "background": {
        "scripts": ["background.js"]
    }
    

    You don’t need content scripts for the purpose of detecting page loads. A single event listener can be used (in the background page):

    chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
        if (changeInfo.status === 'loading') {
            chrome.browserAction.setBadgeBackgroundColor({
                color: 'red',
                tabId: tabId
            });
        }
    });
    

    Have a close look at the documentation of chrome.browserAction.setBadgeBackgroundColor. There are also lots of examples using the browserAction API, you should be able to get a working extension yourself by looking at these samples.

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

Sidebar

Related Questions

Is it possible to change the background color of the vote button in below
Possible Duplicate: Android Button: set onClick background image change with XML? I need that
Is it possible to change slider bar button(for reading numeric values) in any custom
What is the easiest way to change the background color of a toggle button
Right now I am trying to change the background color of a org.eclipse.swt.widgets.Button with
Possible Duplicate: Change custom color for Rectangle.Fill or Grid.Background I'm trying to dynamically set
Is it possible to change a button from disabled to enabled once the value
Possible Duplicate: Change the URL in the browser without loading the new page using
Is it possible to change the color of View Results text in below ?
Is it possible to change C#'s built-in Vector3 struct to not use floating point

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.