2012-04-02 78 views
-1

我得到這個錯誤Mozilla的擴展錯誤

Timestamp: 4/2/12 11:56:36 AM 
Error: uncaught exception: 
    [Exception... "Component returned failure code: 0x80040111 
    (NS_ERROR_NOT_AVAILABLE) [nsIDOMWindow.localStorage]" 
    nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" 
    location: "JS frame :: chrome://myextension/content/users.js 
    :: startFBP :: line 6" data: no] 

我的文件:

chrome.manifest用於

content myextension chrome/content/ 
content myextension chrome/content/ contentaccessible=yes 
overlay chrome://browser/content/browser.xul chrome://myextension/content/tracker.xul 

的install.rdf

<?xml version="1.0" encoding="UTF-8"?> 
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:em="http://www.mozilla.org/2004/em-rdf#"> 

    <Description about="urn:mozilla:install-manifest"> 
    <em:id>[email protected]</em:id> 
    <em:version>2.0</em:version> 
    <em:type>2</em:type> 

    <!-- Target Application this extension can install into, 
     with minimum and maximum supported versions. --> 
    <em:targetApplication> 
     <Description> 
     <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> 
     <em:minVersion>1.5</em:minVersion> 
     <em:maxVersion>13.0.*</em:maxVersion> 
     </Description> 
    </em:targetApplication> 

    <!-- Front End MetaData --> 
    <em:name>myextension</em:name> 
    <em:description>My Extension! Una extensión que te permite añadir funciones únicas a tus redes sociales</em:description> 
    <em:creator>Four Bananas</em:creator> 
    <em:homepageURL>http://myextension.me/</em:homepageURL> 
    </Description>  
</RDF> 
+2

請確認這個位置:「JS frame :: chrome://myextension/content/users.js' – linguini 2012-04-02 20:17:28

+1

JS頁面的第6行有錯誤,如果你認爲某個組件有問題,更新你的FF&檢查出來 – linguini 2012-04-03 04:17:21

+1

這個例外清楚地表明錯誤在文件'users.js'中,函數'startFBP'.那麼你爲什麼要引用完全不相關的'install.rdf'和'chrome.manifest'而不是引用錯誤發生的代碼?另外,請提及這段代碼在哪個上下文中運行 - 瀏覽器窗口? – 2012-04-03 08:07:00

回答

3

即使問題中幾乎沒有有用的信息,但例外情況表明訪問window.localStorage時出現錯誤。我的心理能力告訴我,您正試圖在chrome://加載的文檔中訪問window.localStorage,可能是瀏覽器窗口的XUL文檔。這將不起作用:localStorage始終綁定到服務器主機名,這意味着只有從http://加載的文檔才具有該名稱。

在擴展中,您可以使用不同的機制來持久存儲數據,最常見的是preferences