同源策略

2008年05月29日 Web开发, 翻译

由于Web浏览器必须遵守同源策略,因此客户端的Ajax应用程序一般不能与第三方服务器通信。这一策略规定JavaScript代码只能访问其来源服务器上的数据。事实上,这一策略是非常必要的。如果没有这个策略,那么在另一个域的另一个窗口中运行的JavaScript就有可能修改当前窗口中的HTML。而且,谁也无法确定自己正在查看的页面,是否来源于浏览器地址栏中显示的域。有了这个策略之后,我们就能知道自己正在查看的页面确实来自于正在浏览的域。
对Ajax应用程序而言,这一策略也会限制从其他域以异步方式下载数据;也就是说,只能从加载当前应用程序的服务器上加载数据。考虑到Ajax应用程序可用的众多Web服务,应该说这是一个太不合适的限制。

Tags:



朋友们的留言

  1. UGG Sheepskin Boots Australia | 09月 19th, 2011 at 09:14

    very nice post, i certainly love this website, keep on it.

    Reply to this comment
  2. Ed Hardy T Shirts | 10月 5th, 2011 at 15:40

    Who has deceiv'd thee so oft as thy self?

    Reply to this comment
  3. ugg ブーツ | 10月 31st, 2011 at 14:16

    Thanks a lot for sharing this with all of us you really realize what you are speaking approximately! Bookmarked. Thank you!

    Reply to this comment

我来说两句儿

可以在留言中使用以下标签 :<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree