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/Adding_search_engines_from_web_pages
[2]
http://lxr.mozilla.org/mozilla/source/browser/components/sidebar/src/nsSidebar.js#193
My goal is for onclick handlers on link elements in web pages to call
custom functions in my chrome extension.
--
Brian King
www.mozdev.org - free project hosting for the Mozilla community
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/Code_snippets:Interaction_between_privileged_and_non-privileged_pages
Nickolay
>On 10/9/07, Brian King <br...@mozdev.org> 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/source/browser/components/sidebar/src/nsSidebar.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.
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/Code_snippets:Interaction_between_privileged_and_non-privileged_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.
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).
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
Nickolay
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).
> > 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