admin管理员组文章数量:1252682
I have a local html file with an ajax function trying to pull a xml content from x. The file when run works only on IE and fails on firefox and safari browsers. Ofcourse this may be because of the Same origin policy. But,I have heard from someone that for scripts loaded using file:// protocol,this same origin policy will not apply. Is it true and if yes, what can be problem with my local html file?
I have a local html file with an ajax function trying to pull a xml content from x.. The file when run works only on IE and fails on firefox and safari browsers. Ofcourse this may be because of the Same origin policy. But,I have heard from someone that for scripts loaded using file:// protocol,this same origin policy will not apply. Is it true and if yes, what can be problem with my local html file?
Share Improve this question asked Oct 21, 2010 at 14:24 chedinechedine 2,3743 gold badges19 silver badges24 bronze badges2 Answers
Reset to default 8It is indeed applied to local files, treating them all as separate domains (this varies by browser, as you're seeing). For example in Chrome you can launch it with a mand line to allow this:
chrome.exe --allow-file-access-from-files
In Mozilla file uri have even stricter same origin policy restrictions.. https://developer.mozilla/En/Same-origin_policy_for_file:_URIs However you can over-ride by asking for permission for global access using:
if (navigator.userAgent.indexOf("Firefox") != -1) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}
catch (e) {
alert("Permission UniversalBrowserRead denied -- not running Mozilla?");
}
}
本文标签: javascriptCross domain ajax fails even for a local fileStack Overflow
版权声明:本文标题:javascript - Cross domain ajax fails even for a local file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740319376a2260942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论