views:

48

answers:

2

According to this video http://www.facebook.com/video/video.php?v=562087699610 modern browsers break same origin policy so javascript can make ajax calls to whatever domain.

Is this true?

If yes, does this mean that this will be natural/acceptable whenever necessary eg to fetch data from my partner applications?

+1  A: 

Perhaps a reference to CORS ?

Matthew Wilson
Didn't know about that! Maybe I should use it already for my production web applications and enforce users to use the latest browsers? =)
weng
+1  A: 

Note that browsers don't enforce this policy for included scripts (the same for included images or CSS). That means that someone can cleverly dynamically add:

<script type="text/javascript" src="http://otherdomain/something.js"&gt;&lt;/script&gt;

In order to have cross-domain data. This is possible even without using CORS.

Look at JSONP at Wikipedia.

Denilson Sá
Will this be deprecated in favor of CORS in the future?
weng
I don't know, but probably not. Many people load jQuery and other JavaScript libraries from Google servers. Also, most advertisement today is based on including an external JavaScript. Thus, I believe it won't be removed anytime soon. Also note that CORS support more features than JSONP (HTTP requests other than GET, better error handling...). http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing
Denilson Sá