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://*/*"
]
}