I am attempting to create a new window using JavaScript and populate it with the HTML content from the current window. This is similar to a print preview in a new window, but with a different CSS style.
function openPrintPreview() {
var printWindow = window.open("", "", "width=1020,height=750");
printWindow.document.open();
printWindow.document.write('<html><head><title>Test</title>');
printWindow.document.write('<link href=print.css rel=Stylesheet></head><body>');
printWindow.document.write(document.body.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.focus();
}
The function above is being called from this location:
<a id="print" href="#" runat="server" onclick="javascript:openPrintPreview();">PRINT</a>
When testing in Internet Explorer, I encounter an error message "the remote procedure call failed" that appears to be related to this line:
printWindow.document.close();
In Firefox, everything works as expected. Any suggestions on troubleshooting this issue?
EDIT
My server environment is Windows Server 2008 R2 Standard SP1
EDIT2
Removing printWindow.document.close(); resolves the issue in Internet Explorer, displaying done in the status bar. However, this change causes Firefox to continuously load without completion. It seems like Firefox is waiting for the printWindow.document.close(); command to execute.