简体   繁体   English

使用Javascript获取根页网址

[英]Get root page url using Javascript

i am developing facebook application, and i need to get the facebook root page url not iframe, all these methods: document.location , window.location and top.location ... return the iframe url ( my hosting server ) not facebook url. 我正在开发Facebook应用程序,我需要获取Facebook根目录URL而不是iframe,所有这些方法: document.locationwindow.locationtop.location ...返回iframe url(我的托管服务器)而不是facebook url。

any suggestions ? 有什么建议么 ?

Try parent.location.href . 尝试parent.location.href It might not work if the iframe isn't coming from the same domain, and if so you will just need to get the request url referrer with your server code. 如果iframe不是来自同一个域,则可能无法正常工作,如果是,则只需要使用服务器代码获取请求网址引荐来源网址即可。

Edit: To get the current url in PHP try $_SERVER['HTTP_REFERER'] 编辑:要获取PHP中的当前URL,请尝试$_SERVER['HTTP_REFERER']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM