现在的位置: 首页 > 综合 > 正文

window.open方法中的数值传递

2013年11月04日 ⁄ 综合 ⁄ 共 797字 ⁄ 字号 评论关闭

功能,把子页面的数值传递到父页面中

Parent..htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">
  
function showchild(){
     window.open(
"child.htm","mywin""menubar=no,width=400,height=100,resizeable=yes");
  }

</script>
</head>

<body>
<input type="button" onClick="showchild()" value="showchild"/>
<input type="text" id="parent"/>
</body>
</html>

 child.htm

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">
  
function closechild(){
     
var input=document.getElementById("child");

     window.opener.document.getElementById(
"parent").value=input.value;
     window.close();

  }

</script>
</head>

<body>


<input type="text" id="child"/>
<input type="button" value="close" onClick="closechild()"/>

</body>
</html>

抱歉!评论已关闭.