创建mozilla扩展来显示一个弹出窗口和iframe [英] Create mozilla extension to display a popup and iframe in it
本文介绍了创建mozilla扩展来显示一个弹出窗口和iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的要求是
- 在顶部导航工具栏上添加一个扩展按钮
- 在弹出窗口中显示一个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
- Add a extension button on top Navigation Tool bar
- 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屋!
查看全文