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

164
Visualizações
window.print() not working in browser extension

I am trying to make a print browser extension using window.print() but it is not working, whereas as a separate HTML file it is working.

Below are popup.js and print.html

document.getElementById("m").addEventListener("click", myFunction);

function myFunction() {
  window.print();
}
<!DOCTYPE html>
<html>

<body>
  <h2>The window.print() Method</h2>
  <button id="m"> click me </button>
</body>
<script src="popup.js">
</script>

</html>

manifest file is

{
  "manifest_version": 2,
  "name": "print",
  "version": "0.10002",
  "content_scripts": [{
    "matches": ["<all_urls>"],
    "js": [
      "popup.js",
      "content.bundle.js"
    ],
    "run_at": "document_idle",
    "matches": ["https://*/*"]
  }],
  "browser_action": {
    "default_popup": "print.html"
  },
  "background": {
    "scripts": [
      "background.bundle.js",
      "background.js"
    ]
  },
  "permissions": [
    "storage",
    "https://*/*"
  ]
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

try this:

Below are script.js and file.html

 document.getElementById("btn").onclick = () => window.print();
<!DOCTYPE html>
<html>
<body>

<p>Click the button to print the current page.</p>

<button id = "btn" >Print this page</button>

<script src = "script.js" ></script>

</body>
</html>

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