创建mozilla扩展来显示一个弹出窗口和iframe [英] Create mozilla extension to display a popup and iframe in it

查看:104
本文介绍了创建mozilla扩展来显示一个弹出窗口和iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图开发一个Mozilla的扩展。我只需要在弹出窗口中显示一个iframe,但不知道如何做到这一点。



我的要求是


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

我没有找到类似这样的任何教程。请帮助我。

谢谢...



Hariprasad



在你的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 =iframeContainerContaineralign =top>
< iframe id =myframewidth =100height =100/>
< / vbox>
< / panel>
< / toolbarbutton>
< / toolbarpalette>

然后在你的js文件中:

  function handleOnLoad(){
var iframe = document.getElementById(myframe);
iframe.setAttribute(src,http://www.google.com);





$ b

刚试过这个,它打开一个iframe的谷歌面板: p>


Am trying to develop a mozilla extension. I just need to display an iframe in a popup, but don't know how to do this.

My requirement is

  1. Add a extension button on top Navigation Tool bar
  2. Display an iframe on a popup while clicking on the extension button.

I didn't find any tutorial similar to this. Please help me.

Thank you...

Hariprasad

解决方案

In a xul based extension you can do it like this:

In your xul file:

<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>

And in your js file:

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

Just tried this and it opens a panel with an iframe of google:

这篇关于创建mozilla扩展来显示一个弹出窗口和iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆