如何使用IFRAME将Firefox 2兼容的扩展程序更新到Firefox 3?
时间:2020-03-06 15:04:27 来源:igfitidea点击:
我正在尝试更新为工作中的某些任务创建的自定义Firefox扩展。基本上,它是一个侧边栏,可出于各种目的在iframe中拉出我们的网页之一。移至Firefox 3时,iframe完全不会显示。
以下是一个XUL文件示例,其中包含扩展程序特定的代码(包括iframe),目前仅尝试加载google,但它无法正常工作。我在网上找不到任何引起FF3变化的提及。任何建议,将不胜感激。
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://customsidebar/skin/customsidebar.css" type="text/css"?>
<overlay id="customsidebar-Main" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://customsidebar/content/customsidebar.js"/>
<vbox flex="1">
<toolbar>
<vbox>
<hbox id="customsidebar_TopToolbarRow">
<toolbarbutton label="Refresh" id="customsidebar_Refresh" oncommand="customsidebar_Refresh()" />
</hbox>
<hbox>
<label control="customsidebar_StatusBox" value="Log"/>
<textbox id="customsidebar_StatusBox" multiline="true" rows="1" wrap="off" />
</hbox>
</vbox>
</toolbar>
<iframe id="customsidebar_Iframe" src="http://www.google.com" />
</vbox>
</overlay>
这是叠加层XUL文件
<?xml version="1.0"?>
<overlay id="CustomSidebar-Overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menupopup id="viewSidebarMenu">
<menuitem observes="viewCustomSidebar" />
</menupopup>
<broadcasterset id="mainBroadcasterSet">
<broadcaster id="viewCustomSidebar"
autoCheck="false"
label="CustomSidebar"
type="checkbox" group="sidebar"
sidebarurl="chrome://customersidebar/content/customersidebarMain.xul"
sidebartitle="CustomSidebar"
oncommand="toggleSidebar('viewCustomSidebar');"/>
</broadcasterset>
</overlay>
解决方案
我会尝试在iframe上设置flex =" 1"。如果这不起作用,请尝试使用浏览器元素(而不是iframe)进行尝试。
- 在iframe上设置flex =" 1"
- 侧边栏的XUL代码不是覆盖层,而是一个加载在iframe中的文档(请查看DOM检查器中的Firefox主窗口)。因此,根元素应该是<page>,而不是<overlay>。结合flex =" 1",应该可以显示页面。
- 我们通常希望在iframe上放置type =" content"或者type =" content-primary"。绝对如此,如果我们在其中加载不受信任的页面。

