Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to access the toolbar elements in extension?

5 views
Skip to first unread message

Roger Yu

unread,
Sep 29, 2006, 3:35:08 AM9/29/06
to
I created an extension which contains, in XUL

just added

<toolbox>
<toolbar id="test-toolbar">


<label value="Command:" control="CommandLabel"/>
<textbox id="CommandTxt"/>

<button id="ExecuteBtn" label="Execute" oncommand="test();"/>
</toolbar>

</toolbox>


and in js file that XUL file refers, just add test() function. But if I
want to get the value in the textbox when I click the button, how could
I do?

getElementById looks like only work for Document. But for toolbar
elements, how shall I do?


thanks
Roger

eric...@yahoo.com

unread,
Sep 29, 2006, 4:16:53 PM9/29/06
to Roger Yu, dev-ext...@lists.mozilla.org
Toolbar is in the document, so you can still do:

document.getElementById("CommandTxt").value;

just added

<toolbox>
<toolbar id="test-toolbar">

</toolbox>


thanks
Roger

_______________________________________________
dev-extensions mailing list
dev-ext...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-extensions

Roger Yu

unread,
Sep 29, 2006, 8:42:27 PM9/29/06
to
function test() {
var win=window.content;
var txt=win.document.getElementById('CommandTxt').value;
alert(txt);
}


is this correct? it has no response to me


Thanks
Roger

eric...@yahoo.com 写道:

Roger Yu

unread,
Oct 2, 2006, 3:07:25 AM10/2/06
to
Anyone know this?

Thanks

Roger Yu 写道:

eric...@yahoo.com

unread,
Oct 2, 2006, 1:15:00 PM10/2/06
to Roger Yu, dev-ext...@lists.mozilla.org
Maybe window.contentDocument instead of window.content?

Nickolay Ponomarev

unread,
Oct 2, 2006, 2:10:20 PM10/2/06
to eric...@yahoo.com, dev-ext...@lists.mozilla.org, Roger Yu
On 10/2/06, eric...@yahoo.com <eric...@yahoo.com> wrote:
> Maybe window.contentDocument instead of window.content?
>
No, content.document is fine. contentDocument is a property on
elements like <iframe>, <xul:browser>, while |content| refers to the
|Window| object of the current document.

> ----- Original Message ----
> From: Roger Yu <roge...@msn.com>

> >


> > is this correct? it has no response to me
> >

Read http://developer.mozilla.org/en/docs/Extension_FAQ and check if
there are any errors in JS console.

Nickolay

Nickolay Ponomarev

unread,
Oct 3, 2006, 8:11:47 AM10/3/06
to LouCypher, dev-ext...@lists.mozilla.org
Heh, that's what I get for not reading the original question ;)

Nickolay

On 10/3/06, LouCypher <moz.lo...@gmail.com> wrote:
> Use window.document
>
> function test() {
> var win = window;
> var txt = win.document.getElementById('CommandTxt').value;
> alert(txt);
> }
>
> or just document
>
> function test() {
> var txt = document.getElementById('CommandTxt').value;
> alert(txt);

> --
> LouCypher

0 new messages