[英]Accessing JavaScript variable in an iframe, from the parent window on same domain
[英]Get javascript variable in an iframe from parent window in a different domain
我在域“someplace.com”中有一个iframe被加载到“anotherplace.com”的窗口中。
旧问题表示您无法跨域访问变量: 在该页面内使用iframe共享页面的全局javascript变量
但是现在我们有了CORS,我想知道这是否可行。 如果我们在域之间启用CORS,我们现在能够在iframe的父级中访问JS变量吗?
您需要使用Web Messaging API。
https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.