سؤال

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.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top