javascript的blob构造函数不在safari浏览器中工作

时间:2015-07-13 08:23:16

标签: javascript html safari blobs

任何人都可以帮我解决这个问题。我在我的JavaScript中使用html blob将html网格下载到excel文件中。在Chrome和Mozilla中它的工作正常,但在safari浏览器中显示错误。代码和错误如下:

var uri = 'data:application/vnd.ms-excel;base64,'
      , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->' +
      '<meta http-equiv="content-type" content="text/plain; charset=UTF-8"/><style>thead td{font-weight:bold; background:rgb(149,179,215); color:#fff;}</style></head>' +
      '<body><table><thead><tr><th>CustomerName</th><th>Selected Profile</th><th>Date Range</th></tr></thead><tbody><tr><td>' + customerName + '</td><td>' + worksheetName + '</td><td>' + displayFromDate + ' - ' + displayToDate + '</td></tr></tbody></table>' +
      '<table>{selectorData}</table></body></html>'
      , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
      , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
 var grp = { worksheet: worksheetName || 'Worksheet', selectorData: ctx };
 var blob = new Blob([format(template, grp)], { type: "application/xhtml" });

我在safari中遇到这样的错误:

Type Error: '[object BlobConstructor]' is not a constructor (evaluating 'new Blob([c(h,l)])')

有人可以解决此问题吗?

0 个答案:

没有答案
相关问题