搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

Error when using Components.utils.import

  • 1 个回答
  • 1 人有此问题
  • 1 次查看
  • 最后回复者为 cor-el

more options

Hi ,

I have a web application(CRM) and my clients use it also for the cash register.What I need to do is to create a local file as the cash register's software need's to read from that file in order to print.

Until now i was using this code:

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(filePath);

Unfortunately with the latest version of firefox this isn't working anymore. What I'm trying now starts like this :

try{
    Components.utils.import("resource://gre/modules/FileUtils.jsm");
}catch(e){
 alert(e);
}

Anyhow, from the beginning I get this error "Component.utils is undefined" .Any suggestions please?

Thank you.

Hi , I have a web application(CRM) and my clients use it also for the cash register.What I need to do is to create a local file as the cash register's software need's to read from that file in order to print. Until now i was using this code: <br /> <pre><nowiki>netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); </nowiki></pre> Unfortunately with the latest version of firefox this isn't working anymore. What I'm trying now starts like this : <br /> <pre><nowiki>try{ Components.utils.import("resource://gre/modules/FileUtils.jsm"); }catch(e){ alert(e); }</nowiki></pre> Anyhow, from the beginning I get this error "Component.utils is undefined" .Any suggestions please? Thank you.

由cor-el于修改

所有回复 (1)

more options

This was also posted on the MozillaZine forum site.