JS objects injection before onload event - Mozilla

This is a discussion on JS objects injection before onload event - Mozilla ; I'm writing extension for FF, JavaScript from html pages should be able to obtain information about extension's presence and couple of config parameters. This parameters should be placed inside Window object and should be accessible then onload event fired. I ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: JS objects injection before onload event

  1. JS objects injection before onload event

    I'm writing extension for FF, JavaScript from html pages should be
    able to obtain information about extension's presence and couple of
    config parameters. This parameters should be placed inside Window
    object and should be accessible then onload event fired.

    I tried to use onload event for tabbrowser element, but this one fired
    after page's onload. Then I tried to use nsIWebProgressListener, but
    at the moment have unsolved problem: If I open page via context menu
    in background tab then onLocationChange and onStateChange are not
    called.
    I tried to use TabOpen/TabClose events, but didn't find path to solve
    my problem.

    Does anyone know how to inject JS properties into Window object before
    onload event firing?

    P.S. I checked FireBug sources, but FireBug has the same problem - it
    doesn't insert window.console object in tabs loaded in background.

  2. Re: JS objects injection before onload event

    On Nov 25, 6:45*pm, "John J. Barton"
    wrote:
    > Legaev Andrey wrote:
    > > I'm writing extension for FF, JavaScript from html pages should be
    > > able to obtain information about extension's presence and couple of
    > > config parameters. This parameters should be placed inside Window
    > > object and should be accessible then onload event fired.

    >
    > > I tried to use onload event for tabbrowser element, but this one fired
    > > after page's onload. Then I tried to use nsIWebProgressListener, but
    > > at the moment have unsolved problem: If I open page via context menu
    > > in background tab then onLocationChange and onStateChange are not
    > > called.
    > > I tried to use TabOpen/TabClose events, but didn't find path to solve
    > > my problem.

    >
    > These problems are the reason for bugzilla 342715.
    >
    > > Does anyone know how to inject JS properties into Window object before
    > > onload event firing?

    >
    > > P.S. I checked FireBug sources, but FireBug has the same problem - it
    > > doesn't insert window.console object in tabs loaded in background.

    >
    > Every major version of Firebug has a different implementation of the
    > console: which one did you look at?
    >
    > In Firebug 1.3+ *we try to avoid injecting window.console unless the
    > user is needing it. Thus we have multiple paths to inject it. The path
    > that would support tabs in background is from the javascript debugger
    > detecting that a script is being compiled. *Unfortunately this isn't a
    > general solution because the debugger effectively allows only one client
    > at a time.
    >
    > jjb


    Hi John,

    I tried to solve my problem by creating own Service and attach it to
    Window object through
    Components.interfaces.nsICategoryManager .addCategoryEntry same as in
    nsSidebar.js.
    This approach doesn't allow me to execute script before page
    initialization, but I can inject JS object into page.

    P.S. Thanks for the link to bugzilla.
    P.S.S. I checkouted FireBug 1.2.1 (from http://fbug.googlecode.com/svn/tags/firebug1.2.1),
    will try newer version.

+ Reply to Thread