Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Button's embedded background doesn't work on webpage?

I'm creating a button in javascript and appending it to a HTML page

let dropDownButton = document.createElement('button');
dropDownButton.style.background = "url(/48.png)";
  dropDownButton.style.width = size+"px";
  dropDownButton.style.height = size+"px";
  given.append(dropDownButton);

With 48.png being the local file I wanted to embed. Currently, this code works in an HTML page I declared (created and declared in manifest) but it doesn't work on a webpage (example twitter, with the last empty button being the one I appended).

Why is this happening? Can I fix it or just go back to inserting a img element inside a button?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Wait I fixed it. Simply hardcode the chrome.runtime.getURL method to get local file into the syntax of url()

So instead of

dropDownButton.style.background = "url(48.png)";

use

dropDownButton.style.background = "url("+chrome.runtime.getURL('48.png')+")";

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda