gpt4 book ai didi

javascript - IE9 - 函数错误 : 'ArrayBuffer' is undefined ReferenceError: 'ArrayBuffer' is undefined

转载 作者:行者123 更新时间:2023-12-02 16:56:52 24 4
gpt4 key购买 nike

我创建了一个用于下载pdf的应用程序。 pdf 基于 html 表格。该应用程序在所有浏览器中都工作正常,但是当我在 IE9 中运行时,我收到函数错误:“ArrayBuffer”未定义 ReferenceError:“ArrayBuffer”未定义。由于 IE9 是基于 HTML5 的浏览器,我猜 jspdf 应该可以工作。

<强> Working Demo

function demoFromHTML() {
var pdf = new jsPDF('p', 'pt', 'letter');
pdf.cellInitialize();
pdf.setFontSize(10);
$.each($('#customers tr'), function (i, row) {
if ($(row).text().trim().length !== 0) {
$.each($(row).find("td, th"), function (j, cell) {
var txt = $(cell).text().trim() || " ";
var width = (j == 4) ? 40 : 70;
if (j == 7) {
width = 120;
}
if(i==0)
{
pdf.setFontStyle('bold');
}
else
{
pdf.setFontStyle('normal');
}
pdf.cell(10, 10, width, 18, txt, i);
});
}
});

pdf.save('sample-file.pdf');
}

谁能告诉我一些解决方案

最佳答案

使用以下代码启用downloadify:

<!doctype>
<html>
<head>
<title>jsPDF</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<script type="text/javascript" src="../libs/base64.js"></script>
<script type="text/javascript" src="../jspdf.js"></script>
<script type="text/javascript" src="../libs/downloadify/js/swfobject.js"></script>
<script type="text/javascript" src="../libs/downloadify/js/downloadify.min.js"></script>
</head>

<body onload="load()">
<h1>jsPDF Downloadify Example</h1>

<p>This is an example of jsPDF using <a href="http://www.downloadify.info/">Downloadify</a>. This works in all major browsers.</p>

<p id="downloadify">
You must have Flash 10 installed to download this file.
</p>

<script type="text/javascript">
function load(){
Downloadify.create('downloadify',{
filename: 'Example.pdf',
data: function(){
var doc = new jsPDF();
doc.text(20, 20, 'PDF Generation using client-side Javascript');
doc.addPage();
doc.text(20, 20, 'Do you like that?');
return doc.output();
},
onComplete: function(){ alert('Your File Has Been Saved!'); },
onCancel: function(){ alert('You have cancelled the saving of this file.'); },
onError: function(){ alert('You must put something in the File Contents or there will be nothing to save!'); },
swf: '../libs/downloadify/media/downloadify.swf',
downloadImage: '../libs/downloadify/images/download.png',
width: 100,
height: 30,
transparent: true,
append: false
});
}
</script>
</body>
</html>

使用以下代码延迟加载Downloadify:

<script id="jspdf" src="../jspdf.js"></script>

<script id="lazy">
var jspdfScript = document.getElementByid('jspdf');
var swfobjectScript = document.createElement('script');
var downloadifyScript = document.createElement('script');

swfobjectScript.src = "../libs/downloadify/js/swfobject.js";
downloadifyScript.src = "../libs/downloadify/media/downloadify.swf";

if (window.ActiveXObject)
{
document.documentElement.insertBefore(jspdfScript, swfobjectScript);

swfobjectScript.onload = function () {
document.documentElement.insertBefore(jspdfScript, downloadifyScript);
};

downloadifyScript.onload = function () {
load();
}
</script>

关于javascript - IE9 - 函数错误 : 'ArrayBuffer' is undefined ReferenceError: 'ArrayBuffer' is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26103091/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com