From dc547108e1d85c2dd241d329e0858dced90bf92c Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 18 Apr 2018 22:30:26 -0400 Subject: handle firefox's window.close() permission denied --- print/resources/inkstitch.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'print/resources') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 25a5354e..498b1211 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -213,6 +213,18 @@ $(function() { $.post('/shutdown', {}) .done(function(data) { window.close(); + + /* Chrome and Firefox both have a rule: scripts can only close windows + * that they opened. Chrome seems to have an exception for windows that + * were opened by an outside program, so the above works fine. Firefox + * steadfastly refuses to allow us to close the window, so we'll tell + * the user (in their language) that they can close it. + */ + setTimeout(function() { + document.open(); + document.write("" + data + ""); + document.close(); + }, 1000); }); }); @@ -240,7 +252,6 @@ $(function() { $('select#printing-size').change(function(){ var size = $(this).find(':selected').val(); $('.page').toggleClass('a4', size == 'a4'); - console.log("" + Date.now() + "paper size changed"); $.postJSON('/settings/paper-size', {value: size}); }); -- cgit v1.2.3