开发者

Get IFrame parent url or referrer using javascript or php

开发者 https://www.devze.com 2022-12-29 12:53 出处:网络
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 IFrame in javascript and/or

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 IFrame in javascript and/or PHP? The IFrame loads a php file.

I have tried "parent.top.location.href" and "parent.document.referrer" in the IFrame page but that is undefined开发者_开发问答.

I have also tried to echo "$_Server[referrer]" in the IFrame page and that did return the IFrame parent URL, but how easy is it for someone to manipulate the referrer variable? I dont want to get misleading information.


I have also tried to echo "$_Server[referrer]" in the IFrame page and that did return the IFrame parent URL, but how easy is it for someone to manipulate the referrer variable? I dont want to get misleading information.

If this is a concern, give up. The referrer can always be trivially modified. It should never, ever be relied upon for anything important.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号