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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:38:21+00:00 2026-06-09T18:38:21+00:00

The resize event doesn’t work on content scripts in the Add-on SDK (1.8) this

  • 0

The resize event doesn’t work on content scripts in the Add-on SDK (1.8)
this script: https://builder.addons.mozilla.org/package/142401/latest/

main.js:

var Widget = require("widget").Widget;
var tabs = require('tabs');
var self = require('self');
var data = self.data;
var PageMod = require('page-mod').PageMod;

exports.main = function() {

    PageMod({
        include: [data.url("thepage.html")],
        contentScriptWhen: 'start',
        contentScriptFile: [data.url('thescript.js')],
        onAttach: function(worker) {
                console.log("attaching...")
        },
    });

    new Widget({
        id: "my-widget-1",
        label: "Widget",
        contentURL: "http://www.mozilla.org/favicon.ico",
        onClick: function(event) {
            tabs.open(data.url("thepage.html"));
        }
    });
};

thescript.js

console.log('started')
window.onresize = function(){console.log('resized!!!');}; //not working, never calls

How can I make an resize event triggers inside the content script ?

  • 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-09T18:38:23+00:00Added an answer on June 9, 2026 at 6:38 pm

    It is generally not recommendable to use window.onfoo to attach event listeners. There can be an issue if some other code tries to attach an event listener the same way (one event listener will win and you don’t know which one), and it won’t work if you access window through a wrapper rather than directly. So it is always better to use addEventListener method instead:

    window.addEventListener("resize", function() {
      console.log('resized!!!');
    }, false);
    

    In your case this actually fixes the problem – the event listener fires when the window is resized.

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

Sidebar

Related Questions

The window.resize event in IE doesn't do what I thought it does. I thought
This question relates closely to the stack overflow question " window.resize event firing in
I cant for the life of me figure out why this doesn't work: javascript:
I want to resize my browser window, but my code doesn't work for Chrome.
Possible Duplicate: JQuery: $(window).resize() doesn't work on Load I have the below jQuery function.
I want to edit the css of a div element during .resize() event and
I have a listbox and a panel. In my forms resize event, my listbox
I need resize this image proportionally heigth 411px. how do this? [HttpPost] public WrappedJsonResult
b.driver.manage.window.resize_to(1000, 1000) That line above doesn't work with chrome on my mac. I am
I want to resize the dialog dynamically just before I open it, but this

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.