0
votes

I am working on a add-on project for FireFox using SDK (JPM) and when I run the code in JPM I get "document is not defined"

My index.js file has the following which this error refers to:

var insecure = document.querySelectorAll('[src^="http://"],[href^="http: //"],[img^="http://"]');

Any help would be great as I have tried so many things

Thanks

2

2 Answers

2
votes

Add-on SDK uses a CommonJS module system, it means that the index.js is a sandboxed module, and therefore there is no specific document or DOM associated with it.

If you want access to a content document, you probably want to use content scripts. Take a look here: https://developer.mozilla.org/en/Add-ons/SDK/Guides/Two_Types_of_Scripts and here: https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts

Hope it helps.

1
votes

This issue has now been resolved. I have used content scripts and the "port.emit" port.on" options. Sorry I was late responding.