0
隨着Firefox 16新版本的發佈,我的擴展產生了一個錯誤:「拒絕訪問屬性'myVarExt'的權限」。我無法訪問變量我的擴展名Firefox從iframe
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';
...
次
訪問變量myVarExt iframe的這樣:
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這一呼籲的工作和新的沒有。可能是什麼問題?