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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:04:01+00:00 2026-06-13T00:04:01+00:00

As the questions says, I just want to know the difference between background script

  • 0

As the questions says,
I just want to know the difference between background script and content script in chrome extension. When I logged the chrome object in both the scripts, I found the different objects.

Use case

I want to inject my javascript into the page when the icon is clicked So in manifest.json I added a content script but I am unable to listen to icon click event inside content script.

chrome.browserAction is not defined in chrome object in content script.

Question

How can I listen to click event in content script. Can we include both background and content script ?

This is my manifest.json

{
  "name": "First Plugin Testing",    
  "version": "1.0",
  "manifest_version": 2,    
  "description": "Trying hands on first extension",
  "background": { "scripts": ["background.js"] },
  "browser_action": {
    "default_icon": "icon.png"
  },
  "permissions": [
    "tabs", "http://*/*", "https://*/*"
  ],
  "content_scripts": [
    {
      "matches": ["http://*/*"], 
      "js": ["temp.js"]
    }
  ]
}
  • 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-13T00:04:02+00:00Added an answer on June 13, 2026 at 12:04 am

    I have found the answer to the questions asked.

    A. Can we include both content script and background script ?

    Yes, we can include both the background scripts and content scripts in manifest.
    To do interaction between them you can use Chrome Message Passing API.

    I was doing the same way but there was some error in background script which I could not see therefore I posted this question after some searching on google.

    B. How can I listen to click event in content script ?

    Solution: We can not have browser click event in content script. It has only partial access to chrome object So you have to receive the click handler in background script and send message to content script and do whatever you want.

    Use chrome.browserAction.onClicked event in background script and then use message passing to send the information to content script that user clicked on icon.

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

Sidebar

Related Questions

The question says it all. Basically, I just want to know the alternative for
The questions says it all, just wondering, in an interview, what would you say
Question says it all. I'm just having trouble figuring this out. What i'm trying
Just as the question says, I'm stuck with .Net 2.0 here in my company
This is just an I am Curious question. In C#-in-depth Jon Skeet says about
The questions says it all. Say I have a layout mylayout |-- widgetA `--
Question says it all. Does anyone know if the following... size_t div(size_t value) {
Quick question, I am working on an APNS enabled app and I just want
I want to know how instead of running gcc -std=c99 foo.c -o foo -lcs50
3 Matlab questions 1 - Does anyone know if there is an equivalent to

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.