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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:14:16+00:00 2026-05-18T00:14:16+00:00

I am working on a Firefox extension, and I am trying to pass a

  • 0

I am working on a Firefox extension, and I am trying to pass a parameter to addEventListener. I am “listening” for changes in the page title, my code looks something like this:

function Test()
{
    this.checkTitle = function( event )
    {
        var func = function() { this.onTitleChange ( event ); };
        var target = content.document.getElementsByTagName('TITLE')[0];
        target.addEventListener('DOMSubtreeModified', func, false);
    }

    this.onTitleChange = function( e )
    {
        // do stuff with e
        alert('test');
    }

    this.handleEvent = function (event)
    {
        switch (event.type)
        {
            case "DOMContentLoaded":
            {
                this.checkTitle( event );
            }
        }
    }

    window.addEventListener ("DOMContentLoaded", this, false);
}

I never get the ‘test’ alert, if I use func = function() { alert(event); }; it does show an alert with ‘[object Event]’. Also tried without using this. on func but still wont work.

How can I make this work to be able to access checkTitle parameter “event” into onTitleChange?

  • 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-18T00:14:17+00:00Added an answer on May 18, 2026 at 12:14 am

    When the browser calls the event handler, this will refer to the element, not your instance.

    You need to save a copy of the desired this in a separate variable:

    var self = this;
    
    var func = function(e) { self.onTitleChange (e); };
    var target = content.document.getElementsByTagName('TITLE')[0];
    target.addEventListener('DOMSubtreeModified', func, false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a minimal Firefox extension that loads a web page into an
I am working on a Firefox extension, and in that extension I am trying
I am trying to execute the following code from a firefox extension but it
I'm working on a Firefox extension and I'm trying to stringify a JSON object.
I am trying to write my first hello world extension for Firefox. It's working
Good day everyone. I am working on a Firefox extension, and I want to
t.tBodies(0).appendChild(r); is not working in firefox. This is javascript code and used to create
Hi Javascript gurus, I have this Javascript code which is working fine on Firefox
I'm working on a Firefox extension that will manipulate highlighted text. On a stand-alone
I am working on a Firefox extension that will involve ajax calls to domains

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.