Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
170 views
in Technique[技术] by (71.8m points)

firefox - Display Javascript "same origin policy" violations

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...