功能,把子页面的数值传递到父页面中
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>
本文介绍了一种通过JavaScript实现子页面与父页面间数值传递的方法。具体来说,当打开一个子页面并在其中输入一些数值后,可以通过调用特定的JavaScript函数将这些数值返回给父页面。
2642

被折叠的 条评论
为什么被折叠?



