在PHP中获取iframe的父URL [英] get the parent url of iframe in PHP

查看:777
本文介绍了在PHP中获取iframe的父URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个可以加载到IFrame中的小部件,用户可以将小部件放在他们自己的网站上。我如何获得在javascript和/或PHP中使用IFrame的网站的URL? IFrame加载一个php文件。

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.

我在IFrame页面尝试了parent.top.location.href和parent.document.referrer但是未定义。

I have tried "parent.top.location.href" and "parent.document.referrer" in the IFrame page but that is undefined.

我还尝试在IFrame页面中回显$ _Server [referrer]并且确实返回了IFrame父URL,但是对于某人来说有多容易操纵referrer变量?我不想得到误导性的信息。
目标:我创建了一个小部件,并希望允许注册用户在其网站上使用该小部件。我希望能够找出谁正在使用小部件,如果未注册的用户在他们的网站上使用它,那么小部件将不会显示

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. The Goal: I created a widget and want to allow registered users to use that widget on their site. I want to be able to find out who is using the widget and if a un-registered user is using it on their site, then the widget would not display

推荐答案

试用:

parent.location.href;

parent.document.URL

这篇关于在PHP中获取iframe的父URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆