显示Javascript“相同来源政策”违规 [英] Display Javascript "same origin policy" violations
问题描述
如何显示Javascript Firefox(3.6.20和Chrome)引发了一个源代码策略违例错误(ext:Firebug,Webdeveloper)?
XMLHttpRequest错误跨域违规。这些错误可以通过 try {...} catch(ignore){}
块来消除。如果您知道请求的实际路径,您可以在Firebug的Net选项卡中进行检查,则所有请求(甚至被同源策略拒绝的请求)将显示在所有部分中,在XHR被同源国政策否认的不是。
I'm developing a mobile app which runs a simple HTTP server and a WebView. The WebView displays an external website which should access the server via javascript (GET). Unfortunately this doesn't work and I assume it's due to the same origin policy but the console doesn't show any errors. I had a similar error before which required me to define "Access-Control-Allow-Origin: *" on the server side. This error already took a while to find because there were no error messages (Firebug "Net" tab showed a completed GET request with empty "response" data). Now I assume a same origin policy violation in the external script, but it's hard to tell because of the missing error messages. The only "hint" I see is in Firebug "Net" tab, showing a connection which "never completes". I checked the packages sent to localhost but there wasn't even a connection attempt => thus I assume the browser is holding it back.
How do I display Javascript "same origin policy" violation errors in Firefox (ext: Firebug, Webdeveloper)?
Firefox(3.6.20 and Chrome) throws an error on XMLHttpRequest cross domain violations. These errors can being silenced by try{...} catch(ignore){}
blocks. If you know the actual path of the request you can check in the Firebug's "Net" tab, all the requests(even those denied by "same origin policy") show in the "All" section, and in the "XHR" section those denied by "same origin policy" don't.
这篇关于显示Javascript“相同来源政策”违规的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!