创建mozilla扩展以在其中显示弹出窗口和iframe

Har*_*anx 4 firefox firefox-addon firefox-addon-sdk

我正在尝试开发一个mozilla扩展.我只需要在弹出窗口中显示iframe,但不知道如何执行此操作.

我的要求是

  1. 在顶部导航工具栏上添加扩展按钮
  2. 在单击扩展按钮的同时在弹出窗口中显示iframe.

我没有找到任何类似的教程.请帮我.

谢谢...

Hariprasad

Fil*_*lva 5

在基于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>
Run Code Online (Sandbox Code Playgroud)

在你的js文件中:

function handleOnLoad() {
    var iframe = document.getElementById("myframe");
    iframe.setAttribute("src","http://www.google.com");
}
Run Code Online (Sandbox Code Playgroud)

刚尝试了这个,它打开了一个带有谷歌iframe的面板:

在此输入图像描述