0

I have multiple subdomains and sometimes i have situation to open main domain from sub-domain using window.open and close after doing certain operation.

While doing this activity I need to access javascript variable set on subdomain during page load from opened popup using window.opener.xxx but it says "security issue frame can not be accessed due to cross origin policy".

I tried document.domin = "maindomain.com"; on subdomain but it failed.

How to do it pls help me.

Thanks

coder
  • 283
  • 4
  • 26

2 Answers2

0

You can pass this variable using querystring like, domain.com/page.html?variable=value and then you can parse that variable using javascript, like this: How can I get query string values in JavaScript?

Community
  • 1
  • 1
IT goldman
  • 23
  • 5
  • If you need this variable at run time (and cross domain) you can use the #hash variable of the address part. see also: http://stackoverflow.com/questions/4122422/cross-domain-hash-change-communication – IT goldman Jun 09 '15 at 13:37
0

Since it's your domain and you have access to the server, you can enable Cross-Origin Resource Sharing.

How To: http://enable-cors.org/

Lance
  • 3,824
  • 4
  • 21
  • 29