Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!