---
title: "弹出页面处理例子"
author: "salute"
date: "2010-10-25T16:34:19Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2010-10-25T16:46:29Z"
id: 793383
url: "https://salute.iteye.com/blog/793383"
---

<span style="color:red">jsp页面控件：</span>
<input class="" type="text" size="15" disabled="disabled" value="社員選択" id="empname">&nbsp;<input type="button" id="empbtn" value="選択" style="width:50;" disabled="disabled" onclick="opendialog()">

<span style="color:red">js：</span>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 <span style="color:darkred">setSelectedEmp</span>(name,id)
{
	$("#empname").attr("value",name);
	$("#hiddencollectioner").attr("value",name);
	$("#hiddencollectionerno").attr("value",id);
	if (name!=null)
	{
		document.getElementById("empname").focus();
	}
}

<span style="color:red">struts-call-config.xml配置文件</span>
<action name="empSearch" class="empSearchAction" method="init">
<result name="success">/callsystem/callsearchnew/empSearch.jsp
</result>
</action>


<span style="color:red"><span style="color:green">//empSearch.action 对应的jsp，返回父页面的js</span></span>

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;
	}
         //<span style="color:green">传给父窗口js：setSelectedEmp方法参数</span>
	fatherDnt.<span style="color:darkred">setSelectedEmp</span>(empName, empId);
	window.close();
}