window.open传值
pay.aspx
OW的方法如下:
contractlist.aspx中双击数据行,把数据行的值传回pay.aspx
<script language="JavaScript" type="text/javascript">
function selectContract(id){
var form = document.form1;
form.elements("txtcontractid").value = id==undefined?"":id;
}
</script>
function selectContract(id){
var form = document.form1;
form.elements("txtcontractid").value = id==undefined?"":id;
}
</script>
<table>
<tr>
<td>采购合同编号:<span class="starred">*</span></td>
<td colspan="3"><span class="editTab"><input name="txtcontractid" id="txtcontractid" value="" type="text" class="TEXT" size="30" maxlength="64" readonly="true"/></span>
<input class="button" type="button" onclick='javascript:OW("contractlist.aspx","");' value="选择采购合同编号"/></td>
</tr>
</table>
<tr>
<td>采购合同编号:<span class="starred">*</span></td>
<td colspan="3"><span class="editTab"><input name="txtcontractid" id="txtcontractid" value="" type="text" class="TEXT" size="30" maxlength="64" readonly="true"/></span>
<input class="button" type="button" onclick='javascript:OW("contractlist.aspx","");' value="选择采购合同编号"/></td>
</tr>
</table>
OW的方法如下:
<script>
/******************************************/
/*功能:弹出窗体 */
/*参数:URL 地址,TYPE 模式/全屏,SC 是否显示滚动条*/
/* iW 宽度,iH 高度,TOP 头部位置,LEFT 左边位置,*/
/* R 改变大小,S 状态栏显示,T,TB 帮助显示*/
/*返回:无 */
/******************************************/
function OW(URL,TYPE,SC,iW,iH,TOP,LEFT,R,S,T,TB)
{
var sF="dependent=yes,resizable=no,toolbar=no,status=no,directories=no,menubar=no,";
sF+="scrollbars="+(SC?SC:"NO")+",";
if (TYPE=="full"){
sF+=" Width=1010,";
sF+=" Height=750,";
sF+=" Top=0,";
sF+=" Left=0,";
window.open(URL, "_blank", sF, false);
return;
}
if (TYPE=="modal"){
sF ="resizable:no; status:no; scroll:yes;";
sF+=" dialogWidth:800px;";
sF+=" dialogHeight:570px;";
if(parent.length<2){
sF+="dialogTop:"+(parseInt(parent.dialogTop)+25)+"px;";
sF+="dialogLeft:"+(parseInt(parent.dialogLeft)+25)+"px;";
}
var alpha = '?';
var _URL = URL;
var unique = (new Date()).getTime();
//如果没有参数
if (_URL.indexOf(alpha) == -1){
_URL+= "?time="+unique;
}
else
{
//如果带有参数,含有‘?’
_URL+= "&time="+unique;
}
//alert(_URL.indexOf(alpha));alert(_URL);
return window.showModalDialog(_URL,window,sF);
}
else if (TYPE=="modeless"){
sF ="resizable:no; status:no; scroll:yes;";
sF+=" dialogWidth:800px;";
sF+=" dialogHeight:570px;";
if(parent.length<2){
sF+="dialogTop:"+(parseInt(parent.dialogTop)+25)+"px;";
sF+="dialogLeft:"+(parseInt(parent.dialogLeft)+25)+"px;";
}
var alpha = '?';
var _URL = URL;
var unique = (new Date()).getTime();
//如果没有参数
if (_URL.indexOf(alpha) == -1){
_URL+= "?time="+unique;
}
else
{
//如果带有参数,含有᾿᾿
_URL+= "&time="+unique;
}
//alert(_URL.indexOf(alpha));alert(_URL);
return window.showModelessDialog(_URL,window,sF);
}
else
{
if(iW!=undefined && iH!=undefined){
sF+=" Width="+iW+",";
sF+=" Height="+iH+",";
}
else{
sF+=" Width=800,";
sF+=" Height=570,";
}
if(window.opener==null || window.opener==undefined){
sF+=" Top=50px,";
sF+=" Left=50px,";
}else{
sF+="Top="+(parseInt(window.screenTop)+20)+"px,";
sF+="Left="+(parseInt(window.screenLeft)+30)+"px,";
}
sF+=" scrollbars=yes,"
window.open(URL, "_blank", sF, false);
}
}
</script>
/******************************************/
/*功能:弹出窗体 */
/*参数:URL 地址,TYPE 模式/全屏,SC 是否显示滚动条*/
/* iW 宽度,iH 高度,TOP 头部位置,LEFT 左边位置,*/
/* R 改变大小,S 状态栏显示,T,TB 帮助显示*/
/*返回:无 */
/******************************************/
function OW(URL,TYPE,SC,iW,iH,TOP,LEFT,R,S,T,TB)
{
var sF="dependent=yes,resizable=no,toolbar=no,status=no,directories=no,menubar=no,";
sF+="scrollbars="+(SC?SC:"NO")+",";
if (TYPE=="full"){
sF+=" Width=1010,";
sF+=" Height=750,";
sF+=" Top=0,";
sF+=" Left=0,";
window.open(URL, "_blank", sF, false);
return;
}
if (TYPE=="modal"){
sF ="resizable:no; status:no; scroll:yes;";
sF+=" dialogWidth:800px;";
sF+=" dialogHeight:570px;";
if(parent.length<2){
sF+="dialogTop:"+(parseInt(parent.dialogTop)+25)+"px;";
sF+="dialogLeft:"+(parseInt(parent.dialogLeft)+25)+"px;";
}
var alpha = '?';
var _URL = URL;
var unique = (new Date()).getTime();
//如果没有参数
if (_URL.indexOf(alpha) == -1){
_URL+= "?time="+unique;
}
else
{
//如果带有参数,含有‘?’
_URL+= "&time="+unique;
}
//alert(_URL.indexOf(alpha));alert(_URL);
return window.showModalDialog(_URL,window,sF);
}
else if (TYPE=="modeless"){
sF ="resizable:no; status:no; scroll:yes;";
sF+=" dialogWidth:800px;";
sF+=" dialogHeight:570px;";
if(parent.length<2){
sF+="dialogTop:"+(parseInt(parent.dialogTop)+25)+"px;";
sF+="dialogLeft:"+(parseInt(parent.dialogLeft)+25)+"px;";
}
var alpha = '?';
var _URL = URL;
var unique = (new Date()).getTime();
//如果没有参数
if (_URL.indexOf(alpha) == -1){
_URL+= "?time="+unique;
}
else
{
//如果带有参数,含有᾿᾿
_URL+= "&time="+unique;
}
//alert(_URL.indexOf(alpha));alert(_URL);
return window.showModelessDialog(_URL,window,sF);
}
else
{
if(iW!=undefined && iH!=undefined){
sF+=" Width="+iW+",";
sF+=" Height="+iH+",";
}
else{
sF+=" Width=800,";
sF+=" Height=570,";
}
if(window.opener==null || window.opener==undefined){
sF+=" Top=50px,";
sF+=" Left=50px,";
}else{
sF+="Top="+(parseInt(window.screenTop)+20)+"px,";
sF+="Left="+(parseInt(window.screenLeft)+30)+"px,";
}
sF+=" scrollbars=yes,"
window.open(URL, "_blank", sF, false);
}
}
</script>
contractlist.aspx中双击数据行,把数据行的值传回pay.aspx
<script language="javascript" type="text/javascript">
function doCheck(id)
{
if(window.opener && window.opener.selectContract)
{
opener.selectContract(id);
window.close();
}
}
</script>
function doCheck(id)
{
if(window.opener && window.opener.selectContract)
{
opener.selectContract(id);
window.close();
}
}
</script>
<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<tr ondblclick="doCheck('<%# Eval("ID")%>')">
<td ><%# Eval("ID")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
<ItemTemplate>
<tr ondblclick="doCheck('<%# Eval("ID")%>')">
<td ><%# Eval("ID")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>