Arn*_*ens 3 firefox firefox-addon firefox-addon-sdk
我想让用户在我的插件的首选项窗口中上传图像(到插件的文件夹).
这是我目前的prefpane
:
<prefpane id="tpt-pane" label="Settings">
<preferences>
<preference id="pref_upload" name="addonname.upload" type="file"/>
</preferences>
<hbox align="center">
<label control="upload" value="The file: "/>
<input type="file" preference="pref_upload" id="upload" />
</hbox>
</prefpane>
Run Code Online (Sandbox Code Playgroud)
我有什么方法可以做到这一点(有一个解决方法)?
好的,这是一个完整的插件示例,向您展示:
GitHub :: Noitidart/PortableTester
单击XPI并下载它,然后将其拖到firefox上进行安装.或者只使用AMO :: GitHub Extension Installer从上面的repo链接安装扩展
所以我做的是创建一个options.xul
文件.并install.rdf
确保你没有设置<em:optionsType>
任何东西.
那么内容options.xul
是这样的:
<?xml version="1.0" ?>
<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<setting title="Image Upload" type="file" pref="extensions.PortableTester@jetpack.image_upload" oninputchanged="alert('path of image is:' + this.value + '\nyou can access this image from your addon or anywhere else by getting the pref value so like this:\n`Services.prefs.getCharPref(\'extensions.PortableTester@jetpack.image_upload\') == `' + Services.prefs.getCharPref('extensions.PortableTester@jetpack.image_upload'))">
Select image to upload
</setting>
</vbox>
Run Code Online (Sandbox Code Playgroud)
所以安装插件后去插件面板.Ctlr转移A.
然后点击选项.你会看到这个:
现在单击浏览并选择一个文件,然后它将提示您,我使用上面oninputchanged
看到的属性options.xul
来提醒值.它将图像的路径保存到一个名为extensions.PortableTester@jetpack.image_upload
你可以将其更改为你想要的任何名称但保留extensions.
前缀的偏好.
您现在可以oninputchanged
使用this.value
或从任何地方,任何插件或任何位置访问命令中的值Services.prefs.getCharPref('extensions.PortableTester@jetpack.image_upload')
归档时间: |
|
查看次数: |
111 次 |
最近记录: |