开发者

Would like to recup a string of a javascript function in a XUL code

开发者 https://www.devze.com 2023-01-17 23:56 出处:网络
I\'m trying to do a plugin for firefox in XUL language. So I got informations in json, I parsed them and I can use the title in javascript.

I'm trying to do a plugin for firefox in XUL language. So I got informations in json, I parsed them and I can use the title in javascript. But I would use it in XUL language.

For exemple, in html you can write : <a href="javascript: function()"> link </a>; So I need to list each title in a menuitem label, but I don't want to hardcode it like that <menuitem label="toto"/> I would like recup the string of my javascript's function and do something like that : "<menuitem label="javascript:function();"/>"

I didn't find anything in internet, so I hope I had good explain my problem and I hope someone could answer it. Thank you.


ok thanks for your answer but I don't really know how inject a new element with javascript in a toolbar, by exemple :

&开发者_StackOverflow社区gt; <button type="menu" label="View">  
> <menupopup id="pblist">
>     <menuitem label="toto"/>   </menupopup> </button>

so there I create a button view in my toolbar with a drop-down list toto and I would add a new dynamic label in my list, something like that but i don't know how do that :

> <script>
>     var list = document.createElement("menupopup");
>     document.body.appendChild(list);
>     menu.appendChild('<menuitem label="titi" />');  </script

vut it doesn't work ... Thanks for your help :)


javascript: has a special meaning ("run this javascript code") in the URL context. You can't use it in other places in HTML (like <button label="javascript:...">). For the same reason you can't use it for menuitem's label.

Your question is not specific to XUL. Setting attributes on elements is done in XUL, just as in HTML, using DOM APIs (element.setAttribute() to set the attribute, document.getElementById() and others for getting the element).

0

精彩评论

暂无评论...
验证码 换一张
取 消