Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello I have the following code to open a print dialouge from the browser, Everything is working fine with Chrome and firefox but im not able to get the print dialouge from IE with all versions, below code is specifically meant for IE11 with onreadystatechange function been added and rest is same for all other browsers where I am getting the print dialouge. I was able to save the pdf and when I try open that pdf from IE, I am getting the print dialouge directly. Also its working fine when I keep any alert inside HandleIFRa...method and somehow its not working without that alert.

<iframe name="pdfIFrame" width="530" height="0" class="co_deliveryPreview_iframe" id="pdfIFrame" src="/V1/Delivery/Print.pdf?deliveryId=i0adc40db00000149c0e4b7102093eb14&rnd=0.18330521875832473#view=Fit&navpanes=0&toolbar=1&scrollbar=0&statusbar=0" frameborder="0" onreadystatechange="Cobalt.Delivery.Pdf.Instance().HandleIFrameOnReadyStateChangedForIE11(this)"></iframe>

HandleIFrameOnReadyStateChangedForIE11: function(theIFrame) {
//alert('HandleIFrameOnReadyStateChangedForIE11');
var doc = null;
//var PDF = document.getElementById(iframeID);
//PDF.focus();
//PDF.contentWindow.print();

try {
doc = theIFrame.contentDocument;
}
catch (e) {
alert(e.message+e.description+e.stack);
doc = theIFrame.ownerDocument;
}
//alert(doc.readyState);
//Cobalt.Widget.DeliveryMessageBox.Instance().RemoveAfterTimeout(1000);
if (doc.readyState == "complete") {
Cobalt.Widget.DeliveryMessageBox.Instance().RemoveAfterTimeout(1000);
}
},
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900