window对象的opener属性

window对象的opener属性
描述:
返回对创建此窗口的窗口的引用。即返回打开该窗口的那个窗口。
语法:
window.opener
 
如下实例:在打开的窗口中更改头象:
01.html文件如下:

<html >
<head>
<title>注册</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
  <table width="300" border="1" align="center" cellpadding="5" cellspacing="2" bordercolor="#000000">
    <tr>
      <td width="111">请选择图像</td>
      <td width="157 "><a href="#" onclick="window.open('face.html','','height=350,width=230');"><img src="face/image135.gif" width="72" height="122" id="myface" border="0"  /></a> </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>
 
 
face.html文件如下:

<html >
<head>
<title>选择头象</title>
<script language="javascript">
 function changeFace(src){
  window.opener.document.getElementById("myface").src="face/image" + src + ".gif"; 
 }
</script>
<style type="text/css">
 img{
  border:none;
 }
</style>
</head>
<body>
<table width="248" border="1" cellpadding="3" cellspacing="2" bordercolor="#000000">
  <tr>
    <td> <a href="javascript:changeFace('135');"> <img src="face/image135.gif" width="72" height="122"  /></a></td>
    <td> <a href="javascript:changeFace('136');"> <img src="face/image136.gif" width="72" height="122" /></a></td>
    <td> <a href="javascript:changeFace('137');"> <img src="face/image137.gif" width="72" height="122" /></a></td>
  </tr>
  <tr>
    <td> <a href="javascript:changeFace('138');"> <img src="face/image138.gif" width="72" height="122" /></a></td>
    <td> <a href="javascript:changeFace('138');"> <img src="face/image139.gif" width="72" height="122" /></a></td>
    <td> <a href="javascript:changeFace('140');"> <img src="face/image140.gif" width="72" height="122" /></a></td>
  </tr>
  <tr>
    <td> <a href="javascript:changeFace('141');"> <img src="face/image141.gif" width="72" height="122" /></a></td>
    <td> <a href="javascript:changeFace('142');"> <img src="face/image142.gif" width="72" height="122" /></a></td>
    <td> <a href="javascript:changeFace('143')"> <img src="face/image143.gif" width="72" height="122" /></a></td>
  </tr>
</table>
</body>
</html>

你可能感兴趣的:(职场,opener,休闲)