弹出页面处理例子
jsp页面控件:
js:function opendialog() { var srcFile = "../callsearchnew/empSearch.action"; var retValue = null; if(navigator.userAgent.indexOf("MSIE")>0){ var winFeatures = "dialogHeight:300px;dialogWidth:500px;edge:sunken;scroll:no;status:no;help:no"; retValue = window.showModalDialog(srcFile,self,winFeatures); }else if(navigator.userAgent.indexOf("Firefox")>0) { var fireFeatures = "dialogHeight:300px;dialogWidth:500px;edge:sunken;scroll:no;status:no;help:no"; //window.open( srcFile,null,fireFeatures); retValue = window.showModalDialog(srcFile,null,fireFeatures); } }
function setSelectedEmp(name,id) { $("#empname").attr("value",name); $("#hiddencollectioner").attr("value",name); $("#hiddencollectionerno").attr("value",id); if (name!=null) { document.getElementById("empname").focus(); } }
struts-call-config.xml配置文件 /callsystem/callsearchnew/empSearch.jsp
//empSearch.action 对应的jsp,返回父页面的js
function doConfirm(){ var empnovalue = document.getElementById("empnovalue").value; if(empnovalue == ""){ alert("社員選択はしていません。"); window.close(); } var empId = empnovalue.split(":");//社員CD var empName = empnovalue.split(":");//社員名 var fatherDnt = null; if(navigator.userAgent.indexOf("MSIE")>0) { fatherDnt = window.dialogArguments; }else if (navigator.userAgent.indexOf("Firefox")>0) { fatherDnt = opener; } //传给父窗口js:setSelectedEmp方法参数 fatherDnt.setSelectedEmp(empName, empId); window.close(); }