addEventListener and window.innerWidth question - Mozilla

This is a discussion on addEventListener and window.innerWidth question - Mozilla ; I am writing an extension for Firefox 1.5. My .xul file contains: window.addEventListener("load", init_rkolinfo, false); Which is used to capture the window loading event. In the init_rkolinfo function I wish to know the size of the window that is loaded ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: addEventListener and window.innerWidth question

  1. addEventListener and window.innerWidth question

    I am writing an extension for Firefox 1.5. My .xul file contains:
    window.addEventListener("load", init_rkolinfo, false);

    Which is used to capture the window loading event. In the init_rkolinfo
    function I wish to know the size of the window that is loaded so that I
    may inhibit the function of my extension if the window width is too
    small.

    However, I find that window.innerWidth and window.outerWidth always
    return a value of 1 when called from my init_rkolinfo function.

    The behavior is as if the window object has been initialized at the
    time that the load event is issued but none of the values has yet been
    filled in.

    Is there a relable way to get this info?


  2. Re: addEventListener and window.innerWidth question

    It appears that

    window.setTimeout("document.getElementById('status-bar-rkolstatus-button').setAttribute('label',
    window.innerWidth)", 1000);

    Does work properly. Why I have to provide a one second delay to get the
    proper value is unknown to me. I am not especially happy with this
    since it feels like a hack.


  3. Re: addEventListener and window.innerWidth question

    matthoff@cox.net wrote:

    >I am writing an extension for Firefox 1.5. My .xul file contains: window.addEventListener("load", init_rkolinfo, false);
    >
    >Which is used to capture the window loading event. In the init_rkolinfo function I wish to know the size of the window that is loaded so that I may inhibit the function of my extension if the window width is too small.
    >

    If you don't explicitly size the window then it is automatically resized
    before it is shown, but you can force this resize by calling
    sizeToContent().

    --
    Warning: May contain traces of nuts.

  4. Re: addEventListener and window.innerWidth question

    I have no interest in resizing the window. I just want to inhibit the
    function of my extension if the user has opened a window above a
    certain size. In order for this to work, I need to get the size of the
    window when it is first opened.


  5. Re: addEventListener and window.innerWidth question

    matthoff@cox.net wrote:

    >I just want to inhibit the function of my extension if the user has opened a window above a certain size.
    >

    The user doesn't give the window any size at all, it opens with the size
    you want.

    --
    Warning: May contain traces of nuts.

  6. Re: addEventListener and window.innerWidth question


    Neil wrote:
    > matthoff@cox.net wrote:
    >
    > >I just want to inhibit the function of my extension if the user has opened a window above a certain size.
    > >

    > The user doesn't give the window any size at all, it opens with the size
    > you want.
    >
    > --
    > Warning: May contain traces of nuts.



    Since the user is opening a new, blank window, the call just forces the
    window size information
    to be immediately loaded into the innerWidth and outerWidth variables
    and there is no other
    effect?


  7. Re: addEventListener and window.innerWidth question

    matthoff@cox.net wrote:

    >Since the user is opening a new, blank window, the call just forces the window size information to be immediately loaded into the innerWidth and outerWidth variables and there is no other effect?
    >
    >

    Oh, you're talking about a web page calling window.open with height and
    width specification? In this case, yes, the window is sized after it has
    loaded, but that should generate a resize event if that helps.

    --
    Warning: May contain traces of nuts.

  8. Re: addEventListener and window.innerWidth question


    Neil wrote:
    > matthoff@cox.net wrote:
    >
    > >Since the user is opening a new, blank window, the call just forces the window size information to be immediately loaded into the innerWidth and outerWidth variables and there is no other effect?
    > >
    > >

    > Oh, you're talking about a web page calling window.open with height and
    > width specification? In this case, yes, the window is sized after it has
    > loaded, but that should generate a resize event if that helps.
    >
    > --
    > Warning: May contain traces of nuts.


    Actually, I was talking about this situation
    I have an extension that puts some information in the status bar
    (bottom right hand corner).
    If the window that is opened (either by the new window command or by a
    script popping up a
    window) is below a certain width, I don't want my extension to try to
    but the information in
    the status bar because it wont fit.

    Therefore, when a window is loaded, I want to get the window width and
    inhibit my extension
    from writing the information to the status bar if the window width is
    below a certain threshold.

    It's just a utility extension that provides status information about a
    SHOUTcast server.

    >From what you are saying, I should proabably be triggering on window

    resize and not window
    load.


+ Reply to Thread