JsPDF - Not allowed to navigate top frame to data URL

后端 未结 14 2231
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:48

    Maybe can help, create a function to export with the download attribute html5:

    var docPdf = doc.output();
    exportToFile(docPdf,defaults.type);
    
    function exportToFile(data,type){
    
        var hiddenElement = document.createElement('a');
        hiddenElement.href = 'data:text/'+type+';filename='+'exportar.'+type+';'+'charset=utf-8,' + encodeURI(data);
        hiddenElement.target = '_blank';
        hiddenElement.download = 'exportar.'+type;
        hiddenElement.click();
    }
    

提交回复
热议问题