In my firefox addon code, if i reference a file inside data
directory, all works fine:
var button = widget.Widget({
id: 'foo',
label: 'bar',
contentURL: data.url('icon.png'),
onClick: function() {
tabs.open(data.url('control.html'));
},
});
But if i put same file into foo
directory, it's can't be referenced anymore (not opened as webpage, not displayed as image etc):
var button = widget.Widget({
id: 'foo',
label: 'bar',
contentURL: data.url('icon.png'),
onClick: function() {
tabs.open(data.url('../foo/control.html'));
},
});
In documentation it's stated that data.url()
works relative to data
directory, but it's unclear is it works only
for data
directory or not? Is it possible to use other top-level directories, or i have no options and need to put all my addon files inside data
directory?
Yes you can. But you can't use the data method.
I don't know how to get the self path to the jar file in SDK. But once you get the self path then you can load that file.
actualy on some thought: Probably do a console.log(data.url('control.html')) that should give you the location to your data folder something like: jar://blah/blah/blah/data/control.html
so do string maniuplation and remove the data to just get jar://blah/blah/blah/
then on to that add jar://blah/blah/blah/foo/stuff in foo.html
something like if foo is in the same directory as data folder. just do a console.log of the data.url('icong.png') and post here and i can help you with the string manipulation