Reputation: 2155
I am developing a firefox extension and create a table and in it add a image , and I create a image with : var _img = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "xul:image");
and then I found I couldn't set its attribute "src" with a local image just like use its Url: chrome:\...., so I have to locate it in a web url:http:\ , but a problem will arise, when the http:\ couldn't be visted, How to do? if can I set the attribute of a image with a local url? Thank you very much!
Upvotes: 1
Views: 763
Reputation: 932
In Firefox 3 onwards chrome
resources can no longer be referenced from within <img>
, <script>
, or other elements contained in, or added to, content that was loaded from an untrusted source. This restriction applies to both elements defined by the untrusted source and to elements added by trusted extensions. If such references need to be explicitly allowed, set the contentaccessible flag to yes to obtain the behavior found in older versions of Firefox.
The contentaccessible flag applies only to content packages: it is not recognized for locale or skin registration. However, the matching locale and skin packages will also be exposed to content.
n.b.: Because older versions of Firefox do not understand the contentaccessible flag, any extension designed to work with both Firefox 3 and older versions of Firefox will need to provide a fallback.
Solution
If your extension is named foo
and your image is located in chrome/content/bar.png
put the following in your chrome.manifest
file:
content foo chrome/content/
content foo chrome/content/ contentaccessible=yes
You can now reference your image using
<img src="chrome://foo/content/bar.png">
--
Taken from https://developer.mozilla.org/en/chrome_registration#contentaccessible
Upvotes: 3