Re: window.external in Firefox - Mozilla

This is a discussion on Re: window.external in Firefox - Mozilla ; On 10/9/07, Brian King wrote: > Hi, > > I always thought that window.external was IE only, but it seems Firefox > has support for it. For example, > window.external.AddSearchProvider(engineURL) can be called from a web > page[1]. > > ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Re: window.external in Firefox

  1. Re: window.external in Firefox

    On 10/9/07, Brian King wrote:
    > Hi,
    >
    > I always thought that window.external was IE only, but it seems Firefox
    > has support for it. For example,
    > window.external.AddSearchProvider(engineURL) can be called from a web
    > page[1].
    >
    > Question: Is it possible, from a chrome extension, to add another
    > function to the window.external object that can be called from random
    > web pages? It is not clear from the code[2] how AddSearchProvider does it.
    >
    > [1]
    > http://developer.mozilla.org/en/docs...from_web_pages
    > [2]
    > http://lxr.mozilla.org/mozilla/sourc...Sidebar.js#193
    >

    http://lxr.mozilla.org/mozilla/sourc...Sidebar.js#309

    309 catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY _CATEGORY,
    310 "external",
    311 SIDEBAR_CONTRACTID,

    So no, "external" is reserved after nsSidebar. You can register your
    own implementation, overwriting the nsSidebar one and forward calls to
    already implemented methods appropriately.

    > My goal is for onclick handlers on link elements in web pages to call
    > custom functions in my chrome extension.
    >

    You could instead use the DOM events:
    http://developer.mozilla.org/en/docs...ivileged_pages

    Nickolay

  2. Re: window.external in Firefox

    Nickolay Ponomarev wrote:

    >On 10/9/07, Brian King wrote:
    >
    >
    >>Question: Is it possible, from a chrome extension, to add another function to the window.external object that can be called from random web pages?
    >>

    >http://lxr.mozilla.org/mozilla/sourc...Sidebar.js#309
    >
    >309 catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY _CATEGORY,
    >310 "external",
    >311 SIDEBAR_CONTRACTID,
    >
    >So no, "external" is reserved after nsSidebar. You can register your own implementation, overwriting the nsSidebar one and forward calls to already implemented methods appropriately.
    >
    >

    Better still, just register your own global property.

    --
    Warning: May contain traces of nuts.

  3. Re: window.external in Firefox

    Nickolay Ponomarev wrote:
    > http://lxr.mozilla.org/mozilla/sourc...Sidebar.js#309
    >
    > 309 catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY _CATEGORY,
    > 310 "external",
    > 311 SIDEBAR_CONTRACTID,
    >
    > So no, "external" is reserved after nsSidebar. You can register your
    > own implementation, overwriting the nsSidebar one and forward calls to
    > already implemented methods appropriately.


    Sounds too risky stomping on the sidebar code.

    >> My goal is for onclick handlers on link elements in web pages to call
    >> custom functions in my chrome extension.
    >>

    > You could instead use the DOM events:
    > http://developer.mozilla.org/en/docs...ivileged_pages


    Yes. I already have something like this going where I register a click
    handler on the sidebar (where the pages will be loaded) and read
    attributes based on the event target. Seems like custom DOM events are a
    more reliable option though.

    --
    Brian King
    www.mozdev.org - free project hosting for the Mozilla community

  4. Re: window.external in Firefox

    Neil wrote:
    >> 309 catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY _CATEGORY,
    >> 310 "external",
    >> 311 SIDEBAR_CONTRACTID,
    >>
    >> So no, "external" is reserved after nsSidebar. You can register your
    >> own implementation, overwriting the nsSidebar one and forward calls to
    >> already implemented methods appropriately.
    >>
    >>

    > Better still, just register your own global property.


    Well, the reason I wanted to use 'external' is because the code could
    work in IE and Firefox (there is an IE version of the extension also).

    --
    Brian King
    www.mozdev.org - free project hosting for the Mozilla community

  5. Re: window.external in Firefox

    Nickolay Ponomarev wrote:
    > On 10/9/07, Brian King wrote:
    >> Hi,
    >>
    >> I always thought that window.external was IE only, but it seems Firefox
    >> has support for it. For example,
    >> window.external.AddSearchProvider(engineURL) can be called from a web
    >> page[1].
    >>
    >> Question: Is it possible, from a chrome extension, to add another
    >> function to the window.external object that can be called from random
    >> web pages? It is not clear from the code[2] how AddSearchProvider does it.
    >>
    >> [1]
    >> http://developer.mozilla.org/en/docs...from_web_pages
    >> [2]
    >> http://lxr.mozilla.org/mozilla/sourc...Sidebar.js#193
    >>

    > http://lxr.mozilla.org/mozilla/sourc...Sidebar.js#309
    >
    > 309 catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY _CATEGORY,
    > 310 "external",
    > 311 SIDEBAR_CONTRACTID,
    >
    > So no, "external" is reserved after nsSidebar. You can register your
    > own implementation, overwriting the nsSidebar one and forward calls to
    > already implemented methods appropriately.
    >
    >> My goal is for onclick handlers on link elements in web pages to call
    >> custom functions in my chrome extension.
    >>

    > You could instead use the DOM events:
    > http://developer.mozilla.org/en/docs...ivileged_pages
    >
    > Nickolay


    Please note that this most likely breaks the (X)HTML validation because
    you (can) add unknown; or should I say "invalid attributes".


    --
    Michael Vincent van Rantwijk
    - MultiZilla Project Team Lead
    - XUL Boot Camp Staff member (ActiveState Training Partner)
    - iPhone Application Developer


  6. Re: window.external in Firefox

    On 10/11/07, Michael Vincent van Rantwijk, MultiZilla
    wrote:
    > > You could instead use the DOM events:
    > > http://developer.mozilla.org/en/docs...ivileged_pages
    > >
    > > Nickolay

    >
    > Please note that this most likely breaks the (X)HTML validation because
    > you (can) add unknown; or should I say "invalid attributes".
    >

    You can always add the new attributes in your own namespace. Not that
    "XHTML validation" in this context should bother anyone.

    Nickolay

  7. Re: window.external in Firefox

    Nickolay Ponomarev wrote:
    > On 10/11/07, Michael Vincent van Rantwijk, MultiZilla
    > wrote:
    >>> You could instead use the DOM events:
    >>> http://developer.mozilla.org/en/docs...ivileged_pages
    >>>
    >>> Nickolay

    >> Please note that this most likely breaks the (X)HTML validation because
    >> you (can) add unknown; or should I say "invalid attributes".
    >>

    > You can always add the new attributes in your own namespace.


    Eh, which name space are you referring to here?

    > Not that
    > "XHTML validation" in this context should bother anyone.


    I think it should, simply because you most likely end up making the same
    kind of mistakes when you work on several (large) projects where one or
    more projects require dynamic (X)HTML insertion (people copy other
    peoples code time after time you know).


    --
    Michael Vincent van Rantwijk
    - MultiZilla Project Team Lead
    - XUL Boot Camp Staff member (ActiveState Training Partner)
    - iPhone Application Developer


  8. Re: window.external in Firefox

    On 10/11/07, Michael Vincent van Rantwijk, MultiZilla
    wrote:
    > > You can always add the new attributes in your own namespace.

    >
    > Eh, which name space are you referring to here?
    >

    Any made-up namespace. Attributes can be in any namespace, you know.

    > > Not that
    > > "XHTML validation" in this context should bother anyone.

    >
    > I think it should, simply because you most likely end up making the same
    > kind of mistakes when you work on several (large) projects where one or
    > more projects require dynamic (X)HTML insertion (people copy other
    > peoples code time after time you know).
    >

    Not going to argue because I don't care.

    Nickolay

+ Reply to Thread