IE9 - 函数错误:'ArrayBuffer'未定义ReferenceError:'ArrayBuffer'未定义 [英] IE9 - Error in function : 'ArrayBuffer' is undefined ReferenceError: 'ArrayBuffer' is undefined

查看:374
本文介绍了IE9 - 函数错误:'ArrayBuffer'未定义ReferenceError:'ArrayBuffer'未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have created an application for downloading pdf. the pdf is based on an html table. The application is working fine in all browser but when i run in IE9 i am getting Error in function : 'ArrayBuffer' is undefined ReferenceError: 'ArrayBuffer' is undefined. Since IE9 is HTML5 based browser jspdf should work i guess.

Working Working

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');
}

任何人都可以告诉我一些解决方案。

Can anyone please tell me some solution for this

推荐答案

使用以下代码启用downloadify:

Use the following code to enable 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:

Use the following code to lazy load 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>

这篇关于IE9 - 函数错误:'ArrayBuffer'未定义ReferenceError:'ArrayBuffer'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆