很简单的javascript,主要语句document.referrer,是获取上一个页的地址,而document.URL是获取本页地址。

解决方案 »

  1.   

    <script>
        var url=location.href;
    </script>
      

  2.   

    window.opener.document.getElementById("FaceID").src="xx.html";
    <script>
    If(parent.window.opener)
    Parent.window.opener.location=”xx.html”;
    </script>加入这些,可以自动更新上级页面
      

  3.   

    var url=window.parent.opener.location.href;  //得到上一级(父)的url
    var url=location.href;                       //得到自身url
      

  4.   

    1.html
    <html>
    <head>
    <title>page1.html</title>
    <script>
        function bf(){
         //在原来URL上追加请求串
            document.location.replace("2.html?PreviousPageURL="+document.location.href);
        }
    </script>
    </head>
    <body>
    This is my HTML page 1.
    <br>
    <input type="button" onClick="javascript:bf();" value="跳转">
    </body>
    </html>
    --------------------------------------------------------------------------------------
    2.html
    <html>
      <head>
        <title>page1.html</title>
    <script>
    //获取前一个URL
        function getPreviousURL(){
         //获取整个URL为字符串
         var locationStr = document.location.href;        
    var previousURL = locationStr.split("=")[1];
    alert("previousURL="+previousURL);
        }
    </script>
      </head>
      
      <body>
        This is my HTML page 2. <br>
        <input type="button" onClick="javascript:getPreviousURL();" value="previousURL">
      </body>
    </html>
      

  5.   

    一般来说,通过脚本修改设置 location 或 location.href 是不会传递上一页地址的。上一也地址是手动点击连接,或者提交form时才有
      

  6.   

    1.html<html>
    <body>
    <script>
    function bf() {
    document.location.replace('2.html')
    }
    </script>
    <input type=button onClick=bf() value=跳转>
    </body>
    </html>
    2.html<html>
    <body>
    <script> 
    var url=document.referrer;   
    alert(url);
    </script>
    </body>
    </html>
    无用