嗨,Html5开发人员和HTML4开发人员也.
我想知道是否有任何方法在window.fileReader和更高版本中支持html5的IE8 API。
守则如下:
if(window.fileReader){
alert("supported"); // in html5 works and fires alert but not in IE8
}
实际上,我想在提交.之前阅读文件的内容。
等待回应..。
发布于 2013-12-12 09:48:43
您需要检查以下几个部分的支持:
//Full File API support.
if ( window.FileReader && window.File && window.FileList && window.Blob )
{
//Supported
}
else alert( "Not supported" );
你的第二个要求:
我还想知道不使用HTML5 fileAPI读取文件内容的方法.但不使用ActiveXObject。
你能做的就是:
document.getElementById( "myForm" ).target = "myIframe"; document.getElementById( "myForm" ).submit();
)。<script>window.parent.someCallbackFunction( theFileCOntents );</script>
)进行回调。发布于 2013-12-12 09:44:43
您可以使用简单的if逻辑检查功能,并在那里包装您的功能。
if ('FileReader' in window) {
// Do something with FileReader since it's supported
} else {
// Do something with your polyfill solution
}
您可以尝试像这样的多填充解决方案(在IE8中工作):https://github.com/Jahdrien/FileReader
发布于 2013-12-12 03:49:47
您可以始终使用尝试捕获来检查浏览器中支持的FileReader()。
try {
var reader = new FileReader();
//do something
}
catch(e) {
alert("Error: seems File API is not supported on your browser");
//do something
}
https://stackoverflow.com/questions/20541611
复制相似问题