JS在window.open中把子窗口参数,变量传递给父窗口


父窗口代码如下
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<button  type="button" onclick="_show_wnd('demo-window-open-child-wnd.php')">先打开子窗口</button><br /><br />

<input id="1500km" type="text" readonly="readonly" />

<script type="text/javascript">
function _show_wnd(url) {
        window.open(url, 'miniwnd', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=200, height=50, left=5, top=150');
}
</script>        


子窗口代码如下
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript">
function _get_val(x){
        opener.document.getElementById('1500km').value=x;
        window.close();
}
</script>

<button  onclick="_get_val('15岁以上的老年人');">点击这里传送参数</button>


程序运行结果如下,点击这里运行看看