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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:48:43+00:00 2026-05-31T05:48:43+00:00

I am building my first extension and have problems getting background page loaded scripts

  • 0

I am building my first extension and have problems getting background page loaded scripts working in content scripts, which brings doubts to if any script loaded on the background page is really available to all content scripts.

I have two javascript files, functions.js and content.js, which both use jQuery. I load jQuery and the function script on the background page to decrease parsing with each site match. Once is enough as they are all functions.

manifest.json NON-WORKING

{
  "name": "extension name",
  "background_page": "background.html",
  "content_scripts": [ {
    "js": [ "js/functions.js", "js/content.js" ],
    "matches": [ "http://*.mysite.com/*" ],
    "exclude_globs": [ "*board*" ],
  } ],
  "version": "0.1"
}

Note: Using “include_globs” to load jQuery of a CDN doesnt work. Emulating @include is a failure, so I had to include jQuery with the extension.

manifest.json WORKING

{
  "name": "extension name",
  "background_page": "background.html",
  "content_scripts": [ {
    "js": [ "js/jquery-1.7.1.min.js", "js/functions.js", "js/content.js" ],
    "matches": [ "http://*.mysite.com/*" ],
    "exclude_globs": [ "*board*" ],
  } ],
  "version": "0.1"
}

Note: Here I removed loading jQuery on the background page.

background.html

<html>
    <head>
        <script src="js/jquery-1.7.1.min.js"></script>
        <script src="js/functions.js"></script>
    </head>
</html>

content.js

console.log('testing console');  // this works
alert('testing native JS');  // this works
$('<div id="myTestingDiv" />').prependTo('body');  // this fails
  • 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-05-31T05:48:45+00:00Added an answer on May 31, 2026 at 5:48 am

    Background pages, pop-up pages and Content scripts all run in a different scope and document.

    Any variables and script defined at the Background page are not directly accessible in Content scripts, and vice versa.
    Injected Content scripts, on the other hand, can interact with each other.

    You can get to the global (window) objects using:

    • Get window of the Background page: chrome.extension.getBackgroundPage()
    • Get any/all window objects in the current extension: chrome.extension.getViews()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building my first chrome extension, for that I want to have some
I am building a Magento extension, in which I need to have the following
I have a javascript script in a chrome extension i'm building. It is content
I'm working on making my first Python C extension, which defines a few functions
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I am building my first ASP.Net MVC based app and have a problem accessing
I have been slowing learning and building my first android app. I'm VERY new
I'm building my first CodeIgniter app - and have a registration form. I'm using
I'm building a Firefox Extension that, among other things, needs to replace body background
I'm building my first ASP.NET MVC application and I am having some troubles with

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.