Note that there are some explanatory texts on larger screens.

plurals
  1. POColorbox doesn't close immediately if calling print() prior to close -- why?
    primarykey
    data
    text
    <p>I'm using Colorbox in iframe mode, and am seeing an odd issue that I would appreciate some help in figuring out. My iframe contains a form and another iframe (which contains a preview of the content to be printed), and on my submit handler for the form, I want to invoke window.print() on the embedded iframe and then close the colorbox. My code is hooked up like so:</p> <pre><code> $('#printer_friendly_form').submit(function () { var previewWindow = $('iframe#print_preview').get(0).contentWindow; setZoom($('html', previewWindow.document), 1); previewWindow.focus(); previewWindow.print(); $('#print_preview').css('visibility', 'hidden'); parent.$.colorbox.close(); return false; }); </code></pre> <p>The "setZoom" bit is a little trick I'm doing to scale the content in the embedded iframe down for a print preview without horizontal scrollbars; prior to printing I'm setting the zoom back to 1 so it prints out properly. I've tried removing this code and it doesn't seem to impact the question at hand.</p> <p>The problem I have is that on Chrome, after I dismiss Chrome's print preview dialog, it takes a good 5-8 seconds before the colorbox finally closes. If I remove the "previewWindow.print()" line, the colorbox closes immediately. From my debugging, Chrome treats print as a synchronous call, so close is called only after the print dialog disappears. But it's called immediately after, and the function returns--so I don't know how to account for the delay in actually closing.</p> <p>I've also found on IE9 that the colorbox closes immediately (even before the print dialog appears, which means IE must be asynchronous). Likewise, Firefox (which also seems to be synchronous like Chrome) dismisses the colorbox immediately after the print dialog is done.</p> <p>Is this a Chrome bug/"feature", or is there something else I should be doing in order to get the dialog to close immediately?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload