简体   繁体   中英

Trouble porting a Chrome extension to Firefox

I am trying to port a chrome extension to firefox.

In chrome I had been accessing a certain image using :

chrome.extension.getURL('img/full_logo.png')

In firefox I tried to achieve the same with the following :

var self = require("sdk/self");
self.data.url('img/full_logo.png');

But the firefox console gives error saying require is not defined which i understand is not a javascript function.

What is this require function? How can I get the URL of the image for my firefox add-on? Any valuable links are also be appreciated.

Why access the image from addon code if you know it's name? When you can directly link to it from your content markup.

Consider this directory structure:

├── data
│   ├── html
│   │   └── ui.html
│   ├── images
│   │   └── image.png
│   └── js
│       └── contentScript.js

Inside ui.html use below to use the image ..

<img src="../images/image.png"></img>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM