关于'HTTP_REFERER'获取URL的问题

mrxiaoluo 2012-07-18 10:09:46
$_SERVER['HTTP_REFERER'] ; 是获取链接或获取提交当前页的父页面URL


那请问下 例如 www.hhhhh.com/index.html

在 www.hhhhh.com 目录下的index.html 页面里面 iframe 一个页面进来http://www.tttt.com/index.php

如下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>

<iframe src="http://www.tttt.com/index.php" frameborder="0" scrolling="no" ></iframe>


</body>
</html>



因为$_SERVER['HTTP_REFERER'] ; 是写在 http://www.tttt.com/index.php 这个文件里面的。
这样的话 $_SERVER['HTTP_REFERER'] 获取得到的URL 是直接获取 当前页面的URL 即http://www.tttt.com/index.php 而不是 www.hhhhh.com/index.html 这个页面的URL

请问像这样做法 怎么样才能获取的是客户直接访问的URL 即获取的URL是www.hhhhh.com/index.html而不是嵌套页面的URL http://www.tttt.com/index.php
...全文
555 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
baoxiaohua 2012-07-23
  • 打赏
  • 举报
回复
肯定可以获得的到,
1.你认真调试一下,最起码先http://www.tttt.com/index.php?url=11,先获取看一下
echo $_REQUEST['url'];能不能输入

2.如果第一步没有问题,再用<script>document.write(url);</script>试一下,完整的应该是
<iframe src="http://www.tttt.com/index.php?url=<script>document.write(parent.location.href);</script>" frameborder="0" scrolling="no" ></iframe>




mrxiaoluo 2012-07-23
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]
<iframe src="http://www.tttt.com/index.php?url=<script>document.write(url);</script>" frameborder="0" scrolling="no" ></iframe>

然后在index.php页中通过$_REQUEST['url']来获取
[/Quote]


好像也读取不了 读取的URL 就是这个http://www.tttt.com/index.php?url= 后台的获取不到
baoxiaohua 2012-07-23
  • 打赏
  • 举报
回复
<iframe src="http://www.tttt.com/index.php?url=<script>document.write(url);</script>" frameborder="0" scrolling="no" ></iframe>

然后在index.php页中通过$_REQUEST['url']来获取
mrxiaoluo 2012-07-23
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
引用 5 楼 的回复:
#1 的代码


[/Quote]


现在是可以获取到 但是就是不知道php怎么获取这个值 然后通过提交一起获取
mrxiaoluo 2012-07-23
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]
#1 的代码
[/Quote]


请问php里该如何获取
一起混吧 2012-07-20
  • 打赏
  • 举报
回复
#1 的代码
mrxiaoluo 2012-07-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
是的。这跟php无关。
[/Quote]

我在www.hhhhh.com/index.html 这个页面里面加上下面的js
<script language = javascript>
var url=window.location.href;
document.write(url);
</script>

这样可以直接输出 RUL

因为 我的http://www.tttt.com/index.php 是一个表单页面,,如何让访问点击提交按钮 获取 这个index.html 的js 这个URl
一起混吧 2012-07-19
  • 打赏
  • 举报
回复
是的。这跟php无关。
mrxiaoluo 2012-07-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
$_SERVER['HTTP_REFERER'] 是链接到当前页面的的上一页的直接页面地址,而你这是要获取父窗口,与referer无关。用js获取:
<script>
document.write(parent.location.href);
</script>
[/Quote]


除了用js 用php 不能直接获取吗
一起混吧 2012-07-18
  • 打赏
  • 举报
回复
$_SERVER['HTTP_REFERER'] 是链接到当前页面的的上一页的直接页面地址,而你这是要获取父窗口,与referer无关。用js获取:
<script>
document.write(parent.location.href);
</script>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧