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

  • Home
  • SEARCH
  • 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 8706337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:35:24+00:00 2026-06-13T03:35:24+00:00

We have created a chrome extension for our app. Where we call a METHOD

  • 0

We have created a chrome extension for our app. Where we call a METHOD from a “js file” on CLICK event of the “extension icon” placed on the navigation bar. For this we use message passing between the app.js (file containing the METHOD to be called on icon click) and background.html (using a js file included in this html).
The script used to pass message is:(from background.html)

chrome.browserAction.onClicked.addListener(function (tab) {
    chrome.tabs.sendMessage(tab.id, "showPopup");
});

and to listen the message :(in app.js)

chrome.extension.onMessage.addListener(function(request) {
   if (request === "showPopup") {
      showPopup();
   }
});

The click event works as expected. But now we want to do same thing in mozilla extension. and we can’t pass message to app.js on the click of the icon,so that it can execute the containing methods.

We have also added the app.js using pageMod, something like this

exports.main = function(options, callbacks) {
  pageMod.PageMod({
    include: ["*"],
    contentScriptWhen: 'start',
    contentScriptFile: [data.url('jquery-1.7.1.min.js'),data.url('app.js')]      
  });
  createAndAddNavBarButton();   
};

function createAndAddNavBarButton() {
   var navBar = document.getElementById('nav-bar');//assume document has been defined
   if (!navBar){return;};       
   var nbBtn = document.createElement('navbaricon');    
       nbBtn.setAttribute('id', 'navButton');
       nbBtn.setAttribute('image', data.url('icon_16.png'));        
       nbBtn.onclick = function(){
           showPopup();                    
           return true;
       }    
   navBar.appendChild(btn);
}

But the click event does nothing and showPopup() is undefined. When a new page loads event associated with it in the app.js executes without any error but the click event doesn’t work.

Is there a method from where we can assign click event directly to this icon, as we have done in the case of chrome extension.

  • 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-13T03:35:26+00:00Added an answer on June 13, 2026 at 3:35 am

    Was able to send message to the app.js script by message passing. All we have to do is, add the app.js file within the scope of message passing, so that it can communicate with the javascript.

    nbBtn.addEventListener('click', function() {
       var workers = tabs.activeTab.attach({                    
           contentScriptFile: [ data.url("jquery-1.7.1.min.js"), data.url("app.js")]
       });
       workers.postMessage("doABC");
    }, false) 
    
     navBar.appendChild(nbBtn);
    

    Now in app.js we can receive this message and show the popup

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

Sidebar

Related Questions

I have created the app with forge, and have added in the chrome extension,
I have created a Chrome extension and also published it to tester group on
I created a chrome extension to make things easier at work. We have a
I have created a chrome extension that has a popup with the following HTML
I have created a Chrome extension that uses the hotkeys [Alt]+[0...9] only to discover
I have created a chrome extension for the company I work for, and want
I have created a simple Chrome Extension, but it's not easy for the users
I have created a simple Google chrome extension that overrides CSS classes using the
I have created an omnibar extension that searches our company crm. I want to
I have created 3 classes as following Ext.mine.TextParent - Inherting from Textfield Ext.mine.child.TextChildA -

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.