Access parent URL from iframe

后端 未结 16 1313
野性不改
野性不改 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:30

    If your iframe is from another domain, (cross domain), you will simply need to use this:

    var currentUrl = document.referrer;
    

    and - here you've got the main url!

提交回复
热议问题