【问题标题】:Mozilla Extension errorMozilla 扩展错误
【发布时间】:2012-04-03 16:12:07
【问题描述】:

我收到了这个错误

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

安装.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>firefox@myextension.fourbananas</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>

【问题讨论】:

  • 请检查location: "JS frame :: chrome://myextension/content/users.js
  • JS页面第6行有问题。如果您认为某些组件有问题,请尝试更新您的 FF 并检查一下。
  • 异常清楚地表明错误在文件users.js,函数startFBP。那么为什么要引用与问题完全无关的install.rdfchrome.manifest,而不是引用发生错误的代码呢?另外,请提及此代码在哪个上下文中运行 - 浏览器窗口?

标签: xml firefox firefox-addon xul


【解决方案1】:

尽管问题中几乎没有有用的信息,但异常表明访问window.localStorage 时出错。我的超能力告诉我,您正试图访问从chrome:// 加载的文档中的window.localStorage,可能是浏览器窗口的XUL 文档。这将不起作用:localStorage 始终绑定到服务器主机名,这意味着您只能使用从 http:// 加载的文档。

在扩展中,您可以使用不同的机制来持久存储数据,最常见的是preferences

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多