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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:57:55+00:00 2026-05-25T22:57:55+00:00

In my firefox addon. I have two tabs open in my browser, when I

  • 0

In my firefox addon.
I have two tabs open in my browser, when I try to access the “document” after a interval/timeout, in one of the tabs, I grab the document of another tab instead…

For example:
Tab 1, document.title is: “Test page”
Tab 2, document.title is: “Second tab”

I run a script in tab 1: setTimeout(function(){alert(document.title)}, 5000).
Should alert “Test Page”, but the alert shows “Second tab”.

Here my script:

gBrowser.addEventListener("DOMContentLoaded",function(e){ 
    window = e.originalTarget.defaultView;
    document = window.document;
    setTimeout(function(){ alert(document.title); }, 5000);
}, true);

This only happends when I open the first tab, then a open the second.

The same thing happens when I try to change any dom element.

Also happend when a user click on a button.

How to avoid that?
This could be a bug with firefox or is with me?

  • 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-25T22:57:56+00:00Added an answer on May 25, 2026 at 10:57 pm

    Don’t forget to declare local variables:

    gBrowser.addEventListener("DOMContentLoaded",function(e){ 
        var window = e.originalTarget.defaultView;
        var document = window.document;
        setTimeout(function(){ alert(document.title); }, 5000);
    }, true);
    

    Undeclared variables are automatically global and in particular can change between now and when your timeout runs (never mind lots of other nasty side-effects).

    Even better: switch on strict mode. It will make sure that this mistake produces a visible error and doesn’t go unnoticed.

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

Sidebar

Related Questions

There is an open source firefox addon that I have attempted to test with
I create a firefox addon with the online addon builder. How can one use
I'm developing a firefox addon and would like to have a fixed position (relative
I'm using this javascript code in firefox addon: window.open(link); It opens a link in
I have a question about the log of Firefox Browser. I am implement the
I have created a Selenium test using the Firefox Addon. Now, I want to
I am working on the firefox addon. In this i have to add the
Hi i have this firefox addon i would like it to automatically popup with
I have a Firefox addon available for my website. I add the download link
I have a firefox addon which works for firefox version 3.0 onwards. However, a

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.