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

407
Vistas
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
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