Spaces:
Sleeping
Sleeping
Commit
·
cf5c57c
1
Parent(s):
eba7f1d
adding a delay for window to popup on print
Browse files- scripts.js +11 -5
scripts.js
CHANGED
|
@@ -96,12 +96,17 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
| 96 |
var pageContainer = document.getElementById('brewRenderer');
|
| 97 |
if (pageContainer) {
|
| 98 |
var printWindow = window.open('', 'Print Preview', 'height=800,width=600');
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
printWindow.document.write(`
|
| 107 |
<!DOCTYPE html>
|
|
@@ -138,6 +143,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
| 138 |
</body>
|
| 139 |
</html>
|
| 140 |
`);
|
|
|
|
| 141 |
|
| 142 |
// Wait for the content to be fully loaded before printing
|
| 143 |
printWindow.onload = function() {
|
|
|
|
| 96 |
var pageContainer = document.getElementById('brewRenderer');
|
| 97 |
if (pageContainer) {
|
| 98 |
var printWindow = window.open('', 'Print Preview', 'height=800,width=600');
|
| 99 |
+
if (!printWindow) {
|
| 100 |
+
console.error('Failed to open print window.');
|
| 101 |
+
return;
|
| 102 |
+
}
|
| 103 |
|
| 104 |
+
// Introduce a small delay to allow the window to fully instantiate
|
| 105 |
+
setTimeout(function() {
|
| 106 |
+
if (!printWindow || printWindow.closed || typeof printWindow.closed == 'undefined') {
|
| 107 |
+
console.error('Failed to open print window.');
|
| 108 |
+
return;
|
| 109 |
+
}
|
| 110 |
|
| 111 |
printWindow.document.write(`
|
| 112 |
<!DOCTYPE html>
|
|
|
|
| 143 |
</body>
|
| 144 |
</html>
|
| 145 |
`);
|
| 146 |
+
}, 100); // Delay of 100 milliseconds
|
| 147 |
|
| 148 |
// Wait for the content to be fully loaded before printing
|
| 149 |
printWindow.onload = function() {
|