Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Telefonnummer anzurufen, eine SMS an eine Telefonnummer zu senden oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Learn More

Can't load images on extension

  • 2 Antworten
  • 1 hat dieses Problem
  • 48 Aufrufe
  • Letzte Antwort von Leagon

more options

I'm trying to create an extension that has a menu-like feature, with a "drop-down", which shows more alternatives, however, when I tried to import the image, it didn't work. So I created a "test extension" in which I tried again, in a much more simplified enviroment. However, I don't seem to get this to work (I have included the image in "web_accessible_resources" and used the browser.extension.getURL("image.png"); but It doesn't work), am I doing something wrong, and if so, how are you supposed to do in order to implement images on extensions?

(RenderImage.js): _________________ document.body.style.backgroundImage = browser.extension.getURL("image.png"); _________________ (manifest.json): __________________ {

 "manifest_version": 2,
 "name": "test extension",
 "version": "1.0",
 "web_accessible_resources": [
   "image.png"
 ],
 "content_scripts": [
   {
     "matches": [ "http://example.org/" ],
     "js": [ "RenderImage.js" ]
   }
 ]

} ____________________

(I loaded the extension in the temporary load on about:debugging)

I'm trying to create an extension that has a menu-like feature, with a "drop-down", which shows more alternatives, however, when I tried to import the image, it didn't work. So I created a "test extension" in which I tried again, in a much more simplified enviroment. However, I don't seem to get this to work (I have included the image in "web_accessible_resources" and used the browser.extension.getURL("image.png"); but It doesn't work), am I doing something wrong, and if so, how are you supposed to do in order to implement images on extensions? (RenderImage.js): _________________ document.body.style.backgroundImage = browser.extension.getURL("image.png"); _________________ (manifest.json): __________________ { "manifest_version": 2, "name": "test extension", "version": "1.0", "web_accessible_resources": [ "image.png" ], "content_scripts": [ { "matches": [ "http://example.org/" ], "js": [ "RenderImage.js" ] } ] } ____________________ (I loaded the extension in the temporary load on about:debugging)

Ausgewählte Lösung

Nevemind, solved it by using document.body.style.backgroundImage = "url('" + browser.extension.getURL("image.png") + "')";

Diese Antwort im Kontext lesen 👍 0

Alle Antworten (2)

more options

Hi, just to let you know there are no Developers here just Volunteers. Someone ma know the answer.

You can get help at https://stackoverflow.com/ https://discourse.mozilla.org/c/add-ons and some where in a sub of this : https://www.reddit.com/r/firefox/

more options

Ausgewählte Lösung

Nevemind, solved it by using document.body.style.backgroundImage = "url('" + browser.extension.getURL("image.png") + "')";