FileReader API在jsFiddle中工作,但不是从本地文件中 [英] FileReader API working in jsFiddle, but not from local file

查看:103
本文介绍了FileReader API在jsFiddle中工作,但不是从本地文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究将使用文件API在本地存储文件的Chrome / Firefox扩展。我试图让一个例子正常运行,但我遇到了似乎围绕着Chrome的问题。任何人都可以解释为什么这个jsFiddle 工作正常,但完全相同的代码在从本地文件运行时不起作用。请注意,它在Firefox中正常工作,而不是在Chrome中。任何想法?

I'm working on a Chrome/Firefox extension which will be using the file API to store files locally. I'm trying to get an example up and running but I'm running into issues which seem to center around Chrome. Can anyone explain why this jsFiddle works fine, but the exact same code, when run from a local file, doesn't work. Please note that it works fine in Firefox, just not in Chrome. Any ideas?

推荐答案

Chrome具有异常严格的网络安全性;许多事情,如Ajax,在本地运行时都不起作用。这是其中之一。您可以通过使用本地websever解决此问题,例如@ephemient建议,或者您可以在不安全的模式下运行Chrome进行测试:

Chrome has unusually restrictive web security; many things, like Ajax, won't work when run locally. This is one of them. You can get around this problem by either using a local websever, like @ephemient suggests, or you can run Chrome in unsafe mode for testing:

chrome.exe --disable-web-security

这篇关于FileReader API在jsFiddle中工作,但不是从本地文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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