Access parent URL from iframe

后端 未结 16 1553
野性不改
野性不改 2020-11-22 10:00

Okay, I have a page on and on this page I have an iframe. What I need to do is on the iframe page, find out what the URL of the main page is.

I have searched aroun

16条回答
  •  臣服心动
    2020-11-22 10:38

    You're correct. Subdomains are still considered separate domains when using iframes. It's possible to pass messages using postMessage(...), but other JS APIs are intentionally made inaccessible.

    It's also still possible to get the URL depending on the context. See other answers for more details.

提交回复
热议问题