What Browsers Allow Cross-Origin XMLHttpRequest From Local Files?

心不动则不痛 提交于 2019-12-11 07:04:40

问题


I know Internet Explorer 8 allows cross-domain XHR from LOCAL files, but what about other browsers? I'd like to know about what versions/OS this will work on (if any) for each of the major 5 browsers. Please include any workarounds like Chrome's --disable-web-security flag.

Thanks!


回答1:


well here is a nice blog abt cross domain requests: http://caffeinelab.net/2011/02/08/cross-domain-requests-state-of-the-browsers/

IE provides access control to do cross-domain requests. Now the bad news: as usual, IE can’t do like the others and they have their own non-standard way to provide it.

Instead of a regular XMLHttpRequest, you need to do a XDomainRequest! Moreover, it works only for public pages, not for authenticated pages. So if you need to send he cookies and you want your application to work in IE, you’re pretty much screwed.

and here is how you do it in FFX: http://dirolf.com/2007/06/enabling-cross-domain-ajax-in-firefox.html

Not sure about safari, but Chrome has a command line switch for this:

chrome.exe --disable-web-security

Keep in mind when you enable this you are risking your security when you visit other sites. so be careful

hope this helps




回答2:


In Safari you can enable the Develop menu (Safari → Preferences → Advanced → Show Develop menu in menu bar). There you can disable cross-origin restrictions (Develop → Disable Cross-Origin Restrictions).



来源:https://stackoverflow.com/questions/7141280/what-browsers-allow-cross-origin-xmlhttprequest-from-local-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!