如何更改 Firefox 扩展菜单列表中的选定项目?
我正在编写一个 Firefox 扩展,并且我有一个链接菜单列表,应该自动(在加载时)将其设置为关闭之前设置的最后一个链接。它只是继续设置为第一个菜单项。我尝试过使用 setAttribute('selectedIndex', 1),但这不起作用。 我做错了什么?
一些示例代码:
<menulist>
<menupopup>
<menuitem label="default"/>
<menuitem label="I want this one to be selected" />
<menuitem label="Or this one." />
</menupopup>
</menulist>
I'm writing a firefox extension and I have a menulist of links that should be automatically (upon load) set to the last link it was set before I closed it. It just keep being set to the first menu item. I've tried using setAttribute('selectedIndex', 1), but that doesn't work.
What am I doing wrong?
Some sample code:
<menulist>
<menupopup>
<menuitem label="default"/>
<menuitem label="I want this one to be selected" />
<menuitem label="Or this one." />
</menupopup>
</menulist>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置 selectedIndex 属性,而不是属性。
将其添加到文档后,您通常需要编辑此类内容的属性。
Set the selectedIndex property, not the attribute.
After adding it to the document you usually need to edit properties for things like this.