简体   繁体   中英

Access javascript variable from subdomain

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

您可以使用domain.com/page.html?variable=value这样的querystring传递此变量,然后可以使用javascript解析该变量,如下所示: 如何在JavaScript中获取查询字符串值?

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM