views:

60

answers:

2

I want to develop a extension for firefox. Now I add a image in my project, and I want to use it in my js.because my element is created dynamic,so I didn't get it from xul file. How to get the Image in JS directly?

A: 

You could use a data: URI. Here's an online generator: http://www.scalora.org/projects/uriencoder/

machine elf
A: 

If your image is in the extension package, for example in yourExtension/chrome/skin, you can access it by chrome URL, like this:

var yourImage = new Image(); 
yourImage.src = "chrome://yourExtension/skin/yourImage.png"; 
//do something with yourImage
Manuel Bitto
I add this in my js file ,but it didn't work ,why? In my css file , I add the same path , it can work!
jin
any errors from your error console?
Manuel Bitto