【发布时间】:2012-10-13 12:49:02
【问题描述】:
随着新版本 Firefox 16 的发布,我的扩展程序会产生错误:“Permission denied to access property 'myVarExt'”。
browser.xul
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://mynewext/locale/overlay.dtd">
<overlay id="mynewext-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/x-javascript;version=1.7" src="base.js"/>
<hbox id="browser">
<splitter insertafter="sidebar-splitter"
state="open"
resizebefore="closest"
resizeafter="closest"
id="mynewext-splitter"
hidden="true"/>
<vbox id="mynewext-sidebar"
insertafter="sidebar-splitter"
width="308"
minwidth="308"
maxwidth="308"
collapsed="true">
<tabbox flex="1">
<tabpanels id="mynewext-panels" flex="1">
<iframe id="mynewext-dashboard" flex="1"/>
</tabpanels>
</tabbox>
</vbox>
</hbox>
</overlay>
base.js文件中注册了填充iframe的变量和函数:
base.js
...
var myVarExt='Good!'; //Is the same variable that was accessed
...
var xulContentPanel=_('dashboard');
xulContentPanel.contentDocument.location.href = 'resource://mynewext/html/bodyfirefox.xhtml';
...
这样访问iframe的变量myVarExt:
bodyfirefox.xhtml
<!DOCTYPE HTML><html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>myBar</title>
</head>
<body><div id="testExtVar"></div></body>
<script type="text/javascript" >
var extVar=parent.myVarExt;
document.getElementById('testExtVar').innerHTML = extVar;
</script>
</html>
在旧版本的 Firefox 中,这种呼吁有效,而新版本没有。可能是什么问题?
【问题讨论】: