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

412
Views
Chrome Extention: How to get document.title of the current tab?

In the extention there is a button on the popup page, when I click it I want it to get the title of the current tab. But when I click it, it gives me the title of the popup page. I have tried using chrome.tabs.executeScript() but couldn't make it work. The only time it worked it when I use a backgound.js, but I only want it to do something when I clicked the button. I am really stuck, any help would be apreciated.

Here is the manifest.json

{
    "name": "extention_test",

    "description": "extention descripton",

    "manifest_version": 3,

    "version": "1.0",

    "content_scripts": [{
        "matches": ["https://www.youtube.com/*"],
        "js": ["background.js"],

    }],


    "action": {
        "default_popup": "popup.html",
        "default_title": "test",

    },

    "permissions": [
        "activeTab"
    ]


}

Here is the popup.html

<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>Not This Title</title>
</head>

<body>

    <button id="btn">Click me</button>
    <script src="button.js"></script>


</body>

</html> 

Here is the button.js

const btn = document.getElementById('btn');


btn.addEventListener('click', function handleClick() {


    btn.textContent = 'Button clicked';
    alert(document.title)
   
});
about 4 years ago · Juan Pablo Isaza
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!