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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:42:05+00:00 2026-05-29T07:42:05+00:00

My addon is injecting some content scripts into various websites. After trying to bind

  • 0

My addon is injecting some content scripts into various websites. After trying to bind onbeforeunload or calling window.location.reload I realized that the window object misses some properties.

Is there a way to binding certain events (onbeforeunload, onunload, etc) while injecting code via page-mod module?

I’ve created a test add-on, showing that these properties are missing: https://builder.addons.mozilla.org/addon/1037497/latest/

Solutions on how to use them anyway?

  • 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-29T07:42:05+00:00Added an answer on May 29, 2026 at 7:42 am

    Short answer: You add an event listener using addEventListener() method, like this:

    window.addEventListener("beforeunload", function(event)
    {
      ...
    }, false);
    

    Long answer: For security reasons your content script isn’t communicating with the DOM objects directly, e.g. it cannot see any script-added properties. The technical details also list some limitations:

    Assigning to or reading an on* property on an XPCNativeWrapper of a
    DOM node or Window object will throw an exception. (Use
    addEventListener instead, and use event.preventDefault(); in your
    handler if you used return false; before.)

    In a content script you probably don’t want to replace the web page’s event handlers anyway, rather add your own – that’s what addEventListener() is doing.

    Additional reading

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

Sidebar

Related Questions

I am using the pgbackups addon from Heroku and trying to figure out what
I'm writing a node.js addon in C++. I wrap some class instances using node::ObjectWrap,
I am trying to submit my addon to the mozilla site but I am
Following the advice on google's pagespeed addon, I moved my static content (images, css,
I need to create a simple IE addon, and trying to figure out how
Trying to translate SynoExt addon . I've added to: chrome.manifest : locale synoext en-US
I am trying to create an addon with the new addons builder preview (https://builder.addons.mozilla.org/),
I was trying to create a simple addon for my firefox. What I want
My C# Excel addon is transforming a time series into another time series. Time
In the firefox addon update dialog, a message tip will be displayed which can

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.