开发者

What Browsers Allow Cross-Origin XMLHttpRequest From Local Files?

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 a开发者_开发知识库ny workarounds like Chrome's --disable-web-security flag.

Thanks!


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


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜