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

285
Views
Chrome Extension - javascript return results to popup HTML

I am working on a chrome extension and I cannot figure out how to pass the javascript response returned in popup.js back to popup.html (so the user can see the results). I tried adding <div id="tabs"> </div> into popup.html thinking that would dynamically bring back function(tabs) results but it does not, greatly appreciate any insights.

popup.html

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="myButton.css">
  </head>
  <body style="background-color:Gray;">
     <a href="#" class="myButton">Scan</a>
     <script src=popup.js></script>
     <div id="tabs"> </div>
  </body>
</html>

popup.js

chrome.tabs.query({
    active: true,
    currentWindow: true
}, function(tabs) {
    var tabURL = tabs[0].url;
    var api = "https://api.us-east-2.amazonaws.com..."
    console.log(tabURL);
    console.log(api)
    userdata = {"url":tabURL}
    console.log(userdata)
    
    fetch(api, {
    method: 'POST',
    body: JSON.stringify(userdata),
    })
   .then((resp) => resp.json())
   .then(function(response) {
    console.info('fetch()', response);
    return response;
}); 
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can insert Elements into popup.html with popup.js.

e.g.

function addSpan(response) {
        let tabDiv = document.getElementById('tabs');
        let newSpan = document.createElement('span');
        newSpan.innerText = "Test123".
        // newSpan.innerText = response;
    
        tabDiv.append(newSpan);
}
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!