Open williamyuaus opened 1 year ago
I'm having the same issue as well. Any update on this?
Everything is working properly in firefox but not on chrome.
Same here.
Still having the same issue on Chrome 127.0.6533.90 (Official Build) (64-Bit) on Windows. It's working in Firefox.
The popup opens correctly but opening the print dialogue doesn't seem to work. When disabling autoClose
the popup indefinitely shows a loading animation until you press ESC but I couldn't yet figure out why.
I quickly rebuilt the printing logic and with this document it works flawlessly in Chrome:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Test</h1>
<button id="btn">Print something</button>
<script>
'use strict';
const options = {
name: '_blank',
specs: ['fullscreen=yes','titlebar=yes', 'scrollbars=yes'],
replace: true,
styles: []
}
function printSomething() {
console.log('print');
let win;
win = window.open('', options.name, options.specs.join(','));
if (!win.opener) {
win.opener = window;
}
win.focus();
win.document.write(`
<h1>Print this</h1>
`);
setTimeout(() => {
win.document.close();
win.focus();
win.print();
setTimeout(function () {win.close();}, 100);
}, 1000);
}
document.getElementById('btn').addEventListener('click', printSomething);
</script>
</body>
</html>
@lennaht thanks, that works for me
The popup window will be closed immediately once we clicked the button to print. I tested on the demo website on Chrome: https://mycurelabs.github.io/vue-html-to-paper/#
The Chrome version is Version 115.0.5790.171 (Official Build) (64-bit).