Back to Home

Cross-window communication

The “Same Origin” (same site) policy limits access of windows and frames to each other. The idea is that if a user has two pages open: one from john-smith.com, and another one is gmail.com, then they wouldn’t want a script from john-smith.com to read our mail from gmail.com. So, the purpose of the “Same Origin” policy is to protect users from information theft.

Same Origin [#same-origin]

Two URLs are said to have the “same origin” if they have the same protocol, domain and port. These URLs all share the same origin: - http://site.com - http://site.com/ - http://site.com/my/page.html These ones do not: - http://www.site.com (another domain: www. matters) - http://site.org (another domain: .org matters) - https://site.com (another protocol: https) - http://site.com:8080 (another port: 8080) The “Same Origin” policy states that: - if we have a reference to another window, e.g. a popup created by window.open or a window inside