JsPDF - Not allowed to navigate top frame to data URL

后端 未结 14 2200
Happy的楠姐
Happy的楠姐 2020-11-27 02:53

After updating Google Chrome, the report jsPDF in a new Window does not work any more.

The console shows the message:

Not allowed to navigate

14条回答
  •  执笔经年
    2020-11-27 03:50

    I recently had the same problem using FileReader object to read content and show my JSReport.

     var reader = new FileReader();                        
     reader.onload = function (e) {
          window.open(reader.result, "_blank");
     }
     reader.readAsDataURL(blob);
    

    Unfortunatly after chrome update all my report stopped working. I tried to fix this by using Blob object and it's still working but if you have a popup blocker it will not work.

     var file = new Blob([blob], { type: 'application/pdf' });
     var fileURL = URL.createObjectURL(file);
     window.open(fileURL);
    

    I finally find a way to avoid this problem by creating the iFrame dynamically after reading this topic and i decided to share the solution.

     var file = new Blob([blob], { type: 'application/pdf' });
     var fileURL = URL.createObjectURL(file);
     var win = window.open();
     win.document.write('')
    

提交回复
热议问题