1. 程式人生 > >子視窗呼叫父視窗的另外一種方法

子視窗呼叫父視窗的另外一種方法

父視窗:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
 String path = request.getContextPath();
 String basePath = request.getScheme() + "://"
   + request.getServerName() + ":" + request.getServerPort()
   + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <base href="<%=basePath%>">

  <title>房山百詞測試-EnglishOK</title>

  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
  <link href="<%=request.getContextPath()%>/css/baici/test.css"
   rel="stylesheet" type="text/css" />
  <script language="javascript">
  function setTitle(title){
   if(title)
   document.getElementById("title").innerHTML=title;
  }
  
  function setHeight(height){
   if(height && height>400){
    document.getElementById("myFrame").style.height = height;
   }else{
    document.getElementById("myFrame").style.height = 400;
   }
   
  } 
</script>
 </head>

 <body >
  <div class="logo"></div>
  <div class="tag">
   當前位置:

   <span id="title"></span>
   </strong>
  </div>
  <div id="content">
   <!--插入內容-->
   <iframe scrolling="no"
    src="<%=request.getContextPath()%>/examineeInfo/totestFrame1.action"
    style="background-color: transparent;" frameborder="0"  width="960px"
    allowTransparency="true" id="myFrame"></iframe>
  </div>
  <div id="foot"></div>
 </body>
</html>

------------------------------------------

子視窗呼叫:

<script language="javascript">
  //<!--
  function init(){
   parent.setHeight(500);
   parent.setTitle("測試須知");
  }
  //-->
  </script>
 </head>
 <body onload="init()">