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

170
Views
window.print() no funciona en la extensión del navegador

Estoy tratando de hacer una extensión de navegador de impresión usando window.print() pero no funciona, mientras que como un archivo HTML separado sí funciona.

A continuación se encuentran popup.js e 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>

el archivo de manifiesto es

 { "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 answers
Answer question

0

prueba esto:

A continuación se encuentran script.js y 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 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!