Pergunta

How can i easy access the variable "test" from main.js?

    \my-addon-project
       \data 
         \file.js (var test = "123")
       \lib: 
         \main.js

The main question is, how to include the file.js in the main.js. And how do i get the value of the variable "test".

With require? Searched a few hours for this simple question.

Please help me. Thx.

Foi útil?

Solução

ok make a jsm file, its real simple, here is an example how to make one called hello world:

see the comments bellow the gist it tells you how to access this jsm in another addon, for example purposes it shows how to do it in scratchpad.

https://gist.github.com/Noitidart/9045387

Outras dicas

Looks like you're using the add-on sdk. Here's how to communicate between main.js and content scripts.

All the resources you'll ever need can be found in the docs. So you should only be searching if what you read there is confusing or incomplete.

Add a comment if you have questions about how to navigate the docs.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top