Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda