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

标签 firefox firefox-addon firefox-addon-sdk

我正在尝试开发一个 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");
    }
    

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

    enter image description here

    关于firefox - 创建 mozilla 扩展以在其中显示弹出窗口和 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18506117/

    相关文章:

    css - 从顶级 css 导入 css 被阻止

    javascript - 如何从 firefox-addon/js-ctypes 调用 C++ 类实例?

    firefox-addon - 通过外部脚本和 postMessage 使用 simple-prefs (SDK API)

    javascript - Mozilla 插件。 required(sdk/tabs).attach() 不起作用

    javascript - 一系列下拉菜单,由 jQuery 提供支持,可以隐藏和显示,但在 Chrome 中不行

    javascript - FireBug 的 console.log() 和 console.debug() 有什么区别?

    javascript - 如何在 Firefox 中执行 document.ondrop?

    javascript - 访问我无法控制的特定页面时执行 JavaScript

    javascript - jsctypes 中可以跳过 IID_PPV_ARGS 吗? (Win7)

    javascript - Pale Moon 中的简单 firefox 扩展 "not compatible"错误