get the parent url of iframe in PHP

前端 未结 6 1170
梦毁少年i
梦毁少年i 2021-01-19 12:38

I am creating a widget that would load in a IFrame and users will be able to place the widget on their own website. How would I get the URL of the website that is using the

6条回答
  •  无人共我
    2021-01-19 13:08

    Assuming your widget's URL doesn't do any redirects, etc., you should be able to use:

    document.referrer
    

    from within the javascript inside your iframe and it should contain the URL of the parent page. This seems to be what YouTube does for tracking in their iframe embed codes.

提交回复
热议问题