$_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   

解决方案 »

  1.   

    $_SERVER['HTTP_REFERER'] 是链接到当前页面的的上一页的直接页面地址,而你这是要获取父窗口,与referer无关。用js获取:
    <script>
    document.write(parent.location.href);
    </script>
      

  2.   

      除了用js    用php  不能直接获取吗 
      

  3.   


    我在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 
      

  4.   

    现在是可以获取到  但是就是不知道php怎么获取这个值  然后通过提交一起获取
      

  5.   

    <iframe src="http://www.tttt.com/index.php?url=<script>document.write(url);</script>" frameborder="0" scrolling="no" ></iframe>然后在index.php页中通过$_REQUEST['url']来获取
      

  6.   

    好像也读取不了   读取的URL  就是这个http://www.tttt.com/index.php?url=   后台的获取不到
      

  7.   

    肯定可以获得的到,
    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>