我正在尝试开发一个 mozilla 扩展。我只需要在弹出窗口中显示 iframe,但不知道该怎么做。
我的要求是
- 在顶部导航工具栏添加扩展按钮
- 单击扩展按钮时在弹出窗口上显示 iframe。
我没有找到任何与此类似的教程。请帮我。
谢谢...
哈里普拉萨德
在基于 xul 的扩展中,您可以这样做:
在你的 xul 文件中:
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="mainToolbarIcon"
image='chrome://yourExt/content/images/icon.png'
type="panel"
class="toolbarbutton-1 chromeclass-toolbar-additional">
<panel id="toolbarPanel"
type="arrow"
noautofocus="true"
consumeoutsideclicks="true"
noautohide="false"
onpopupshowing="handleOnLoad();"
level="parent">
<vbox id="iframeContainerContainer" align="top">
<iframe id="myframe" width="100" height="100"/>
</vbox>
</panel>
</toolbarbutton>
</toolbarpalette>
在你的 js 文件中:
function handleOnLoad() {
var iframe = document.getElementById("myframe");
iframe.setAttribute("src","http://www.google.com");
}
刚刚尝试了这个,它打开了一个带有 google iframe 的面板:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)