不允许将顶部框架导航到数据URL:JsPDF

try { var a; var b = new jsPDF("p", "pt", "a3"); var c = document.getElementById("leftPieCanvas").toDataURL("image/png"); b.addImage(c, "PNG", 265, 60); a = document.getElementById("rightPieCanvas").toDataURL("image/png"); b.addImage(a, "PNG", 205, 440); if ($("#sales_table").length) { var d = tableToJson($("#sales_table").get(0)); b.setFont("helvetica"); b.setFontType("bold"); b.setFontSize(9); $.each(d, function(a, c) { $.each(c, function(c, d) { b.cell(40, 830, 55, 20, d, a); }); }); } b.output("dataurlnewwindow"); } catch (e) { alert(e); } 

上面的代码是在firefox中工作,但不是在chrome中,我用google搜索并获得使用iframe的建议,所以我创建了iframe但无法将此代码放在上面的代码中,任何人都可以建议请如何将以下代码添加到上面的代码中我也可以在谷歌浏览器中渲染PDF。

 var html = '' + 'html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} ' + '' + '' + ''; 

  try { var a; var b = new jsPDF("p", "pt", "a3"); var c = document.getElementById("leftPieCanvas").toDataURL("image/png"); b.addImage(c, "PNG", 265, 60); a = document.getElementById("rightPieCanvas").toDataURL("image/png"); b.addImage(a, "PNG", 205, 440); if ($("#sales_table").length) { var d = tableToJson($("#sales_table").get(0)); b.setFont("helvetica"); b.setFontType("bold"); b.setFontSize(9); $.each(d, function(a, c) { $.each(c, function(c, d) { b.cell(40, 830, 55, 20, d, a); }); }); } //b.output('dataurlnewwindow'); var uri = b.output('dataurlstring'); openDataUriWindow(uri); } catch (e) { alert(e); } function openDataUriWindow(url) { var html = '' + '' + '' + '' + ''; a = window.open(); a.document.write(html); } 
   

在纯JavaScript中,也许这样有用:

html:

js: document.getElementById('obj').data = doc.output("datauristring");

如果我错了,请试试纠正我。