Alex Rivera | Logout

How exactly is the same-domain policy enforced?

Asked 2009-05-30T12:40:25.973
13

Let's say I have a domain, js.mydomain.com, and it points to some IP address, and some other domain, requests.mydomain.com, which points to a different IP address. Can a .js file downloaded from js.mydomain.com make Ajax requests to requests.mydomain.com?

How exactly do modern browsers enforce the same-domain policy?

Edit
Report

1 Answer

1

This won't work because the host name is different. Two pages are considered to be from the same origin if they have the same host, protocol and port.

From Wikipedia on the same origin policy:

The term "origin" is defined using the domain name, application layer protocol, and (in most browsers) TCP port of the HTML document running the script. Two resources are considered to be of the same origin if and only if all these values are exactly the same.

answered 2009-05-30T12:48:11.527

Your Answer