So, due to a recent Chrome update preventing a direct url using javaScript: "It is not allowed to navigate to the top frame with the data url", I have a code that I need to change. I have an ajax call that uses mPDF to create a PDF file, sends it back to base 64 and should open in a new tab. It always worked. However, due to this problem, what I'm trying to do now is upload this PDF file to iFrame in a new window to avoid the error. And it works, here is what I have:
$('.print-order-pdf').click(function(){
var orderNumber = $(this).attr('order')
var data = {
pdfnonce: pdfAjax.pdfnonce,
action: 'getOrderPDF',
orderNumber: orderNumber,
}
var win = window.open('', '_blank');
$.post(pdfAjax.ajax_url, data, function(return_url){
win.document.write("<iframe id='pdf' src='"+ return_url +"'></iframe>");
win.document.write("<style> html, body{ overflow:hidden; margin:0; } #pdf{ width:100%; height: 100%; }</style>");
});
});
( Ajax wordPress). - PDF. , Chrome , PDF, . , , , . firefox, . Chrome PDF . ? - Chrome, iFrame? ? ?
.