子窗口调用父页面js实例
父页面代码:
<%@ page contentType="text/html; charset=GBK"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK" /> <title>new_page_title</title> <script type="text/javascript"> //查询信息 function doQuery_new(){ var inputValue = $("#inputValue").val(); alert("doQuery"); } //新增信息 function doOpen_new(){ var dlg = new Dialog("son_Dialog"); dlg.Width = 450; dlg.Height = 150; dlg.Title = "son_Dialog"; //URL为子页面路径 dlg.URL = "/smsadmgr/data/black/sonDialog.jsp"; dlg.ShowMessageRow = false; dlg.parentWindow = window; dlg.OKEvent = function(){dlg.getIFrame().doSubmit()}; dlg.show(); dlg.OKButton.value ="刷新"; } </script> </head> <body onload="doQuery()"> <table id="table" align="left" cellSpacing="2" cellPadding="3" border="0"> <tr> <td class="tdOdd" align="right"><label>手机号码:</label></td> <td class="tdEven"><input type="text" id="inputValue" name="inputValue" value="cwqi_refresh" style="width: 100px" /></td> <td class="tdEven" colspan="6"> <input type="button"onclick="doQuery_new()" value="查询" /> <input type="button"onclick="doOpen_new()" value="打开" /></td> </tr> </table> </body> </html>
子窗口代码:
<%@ page contentType="text/html; charset=GBK"%> <html> <head> <title>son_page</title> </head> <body onload="fillPhone()"> <form name="myForm" id="myForm"><br> <table class="txttable" style="text-align: center; margin-left: 3px; margin-right: 3px"> <tr> <td width="80" align="left">手机号码:</td> <td align="left"><input id="BL_PHONENUM" name="BL_PHONENUM" maxlength="50" value="" style="width: 100px" /><font color="red">*</font> </td> <td width="80" align="left">证件号码 :</td> <td align="left"><input id="ZJ_NUM" name="ZJ_NUM" maxlength="50" value="" style="width: 100px" /><font color="red">*</font> </td> </tr> </table> </form> </body> <script type="text/javascript"> function fillPhone(){ document.getElementById("BL_PHONENUM").value="加载填充"; //$("#BL_PHONENUM").val("加载填充"); } function doSubmit(){ var inputValue=document.getElementById("ZJ_NUM").value; if(inputValue==""){ alert("证件号码不能为空"); return; } alert(inputValue); var dlg = parent.Dialog.getInstance("son_Dialog"); var pframe = dlg.parentWindow; pframe.doQuery(); dlg.close(); } </script> </html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。