草鞋

          Blog grass shoes
          posts - 1, comments - 4, trackbacks - 0, articles - 27
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          JS獲取上一面地址URL

          Posted on 2007-10-23 09:56 草 鞋 閱讀(608) 評論(0)  編輯  收藏 所屬分類: JavaScript

          <%@ page contentType="text/html; charset=UTF-8"%>
          <%@ page import="java.util.Enumeration"%>
          <!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>

          <!-- 用window.location=URL打開時所有方法都不能獲取 -->
          <!-- 用showModalDialog打開時所有方法都不能獲取 -->
          <!-- 用showModelessDialog打開時所有方法都不能獲取 -->
          <%

          //獲取A標簽跳轉的來源頁面的URL
          //out.println("<br>JSP輸出:"+request.getHeader("Referer")+"<br>");
          %>
          <!-- <body onload="setTimeout(cclose(),3000)"> -->
          <body>
          <form id="login" method="get" action="" name="login">

          <br>

          <input type="button" onclick="javascript:window.close();" value="關閉"/>

          <script language="javascript">
          var kk=false;
          var tmpstr=false;
          try
          {
           document.write("<br>JS1輸出:");
           //只能獲取A標簽跳轉的來源頁面的URL
           //document.write(document.referrer);
           alert("'"+document.referrer+"'");
           //document.write("<br>JS2輸出:");
           //只能獲取Open打開的來源頁面的URL
           //document.write(window.opener.location);
           //alert(window.opener.location);
          }
          catch(e)
          {
           tmpstr=e.description;
           alert(tmpstr);
          }
          </script><br>
          </form>
          </body>
          </html>

          主站蜘蛛池模板: 互助| 安远县| 江孜县| 彰武县| 晋江市| 祥云县| 濮阳县| 新河县| 屯昌县| 安图县| 广东省| 治多县| 托克逊县| 东平县| 北碚区| 江北区| 平罗县| 且末县| 南溪县| 达州市| 鄢陵县| 桐庐县| 淮北市| 汶上县| 宁海县| 满洲里市| 木兰县| 达孜县| 沛县| 秦安县| 新田县| 葵青区| 安化县| 宣化县| 麻城市| 永寿县| 红桥区| 玉环县| 三亚市| 靖西县| 新营市|