var child; //initialize as global
$('#printBtn').button().click(function (e) {
var link = 'viewtranslip.html'; //link for generating your pPDF
var html = "<html><head><title></title>";
html += "</head><body style='margin: 0;'>";
html += "<iframe height='100%' width='100%' src='" + link +"'></iframe>";
html += "</body></html>";
child = window.open("", "_blank", "resizable=1,status=0,toolbar=0,menubar=0");
child.document.write(html);
return win;
});
//close child button
$('#doneBtn').button().click(function (e) {
e.preventDefault();
//check if child window is already closed
if (child && !child.closed){
child.close();
}
});
Wednesday, January 28, 2015
Close PDF Child Window in Parent (works in IE, Mozilla, Firefox)
In my previous post, I tried to open a pdf in another window, and when user clicks Done button in the parent window, the pdf (child) window should close. I have successfully achieved this but it didn't work in Internet explorer. But Thank God! I found an alternate fix that will run both in Internet Explorer, Chrome and Mozilla.
Tuesday, January 27, 2015
Close Child Window from Parent Jquery
Open new window (child) from parent
Tested in IE 8, Chrome and Mozilla.
Limitation: If you open a pdf, doc, xls, in child window, this function will return a "Permission Denied" error on the child.close() line. "When Internet Explorer uses an Active Document server, such as Microsoft Word, Microsoft Excel, or Adobe Reader, to display a document in an Internet Explorer window, the page contains only the active document window and not the MSHTML. "
Read more about this limitation at http://support.microsoft.com/kb/934365/
Update: I found a fix that works in Internet Explorer, Mozilla, Chrome
var child; //initialize as global
$('#prinBtn').button().click(function (e) {
child = window.open('viewtranslip.html');
});
//close child button
$('#doneBtn').button().click(function (e) {
e.preventDefault();
//check if child window is already closed
if (child && !child.closed){
child.close();
}
});
Tested in IE 8, Chrome and Mozilla.
Limitation: If you open a pdf, doc, xls, in child window, this function will return a "Permission Denied" error on the child.close() line. "When Internet Explorer uses an Active Document server, such as Microsoft Word, Microsoft Excel, or Adobe Reader, to display a document in an Internet Explorer window, the page contains only the active document window and not the MSHTML. "
Read more about this limitation at http://support.microsoft.com/kb/934365/
Update: I found a fix that works in Internet Explorer, Mozilla, Chrome
Subscribe to:
Comments (Atom)