I have two subdomains www.example.com and api.example.com. On a page from first domain I open popup window with url api.example.com/some/url and want to use window.opener object to pass data to parent page. But I get error:
Unsafe JavaScript attempt to access frame with URL http://www.example.com/some/page from frame with URL http://api.example.com/some/url. Domains, protocols and ports must match.
Is it possible to fix the issue?
It is possible to pass data between http://www.example.com and api.example.com but not with window.opener. You can set a value in a cookie with Javascript (
document.cookie) on the.example.comdomain (not http://www.example.com) and it will be readable on http://www.example.com and api.example.com.On a page from http://www.example.com, if you execute this Javascript:
(source: http://techpatterns.com/downloads/javascript_cookies.php)
then the “somename” cookie will be readable from api.example.com