为什么我在IE中收到此错误:“传递给系统调用的数据区域太小”? [英] Why am I getting this error in IE: "The data area passed to a system call is too small"?

查看:6081
本文介绍了为什么我在IE中收到此错误:“传递给系统调用的数据区域太小”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个使用Javascript下载的csv文件,除了IE(我已经测试过8和10)之外,它在所有方面都运行得很好。

I'm creating a csv file for download using Javascript and it's working perfectly fine in everything except for IE (I've tested 8 and 10).

在IE8中,当我点击按钮创建并下载文件时,我收到一个错误并说传递给的数据区域系统调用太小。在IE10中,当我单击按钮时,它只会打开一个新选项卡,其中包含我在地址栏中创建的URL但不下载任何内容。

In IE8, when I click the button to create and download the file I get an error that comes up and says "The data area passed to a system call is too small". In IE10, when I click the button it just opens a new tab that has the URL I've created in the address bar but doesn't download anything.

任何想法这个错误意味着什么?

Any ideas what this error means?

我在一个按钮中有这个代码:

I have this code in a button:

var csvContent = "data:text/csv;charset=utf-8,";
csvContent += escape(myCSVvariable);

var encodedUri = encodeURI(csvContent);
window.open(encodedUri);

这与这个问题有关但是我开了一个新问题,因为我在更改了一些后出现了不同的错误事情 - 如何创建和下载csv文件使用Javascript?

This is related to this question but I started a new one because I got a different error after changing some things - How do I create and download a csv file using Javascript?

推荐答案

这是一个已知问题,但有一种解决方法。

This is a known issue, but there is a workaround.

添加以下代码

if (navigator.msSaveBlob) 
{ // IE 10+ 
navigator.msSaveBlob(new Blob([csv], { type: 'text/csv;charset=utf-8;' }), "filename.csv"); 
}

,问题应该解决。这适用于IE10,我没有在IE8上测试过(我没有IE8了!)

and the issue should be resolved. This works for IE10, I have not tested it on IE8 (I don't have IE8 anymore!)

参考:

https://msdn.microsoft.com/library/Hh772331

https://msdn.microsoft.com/library/Hh772298

来源

这篇关于为什么我在IE中收到此错误:“传递给系统调用的数据区域太小”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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