asp.net 弹出子窗口

本文介绍如何使用JavaScript实现弹出子窗口及子窗口与父窗口间的数据传递。通过window.open方法可以指定新窗口的各种属性,如位置、尺寸等。同时,演示了如何在子窗口中设置返回值,并将该值传回父窗口。

<script LANGUAGE="javascript"> 

function openwin() {

     window.open("./QuerySjybh.aspx",'newwindow ', 'height=400, width=420, top=0, left=0, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no');

}

</script>  

属性如下:
window.open 弹出新窗口的命令;
QuerySjybh.aspx 弹出新窗口的文件名;
newwindow 弹出窗口的名字(不是文件名),可用空 ″代替;
height=100 窗口高度;
top=0 窗口距离屏幕上方的像素值;
left=0 窗口距离屏幕左侧的像素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏;
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;

 

 

 

2.

javascript弹出子窗口并返回值

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312"   />
< title > 无标题文档 </ title >
</ head >
< script  type ="text/javascript" >
function  returnWin(){
window.returnValue
= document.Form2.TextBox1.value;
window.close();
}
</ script >


< body >
< form  name ="Form2"  id ="Form2" >

< input  name ="TextBox1"  id ="TextBox1"  value ="123"  type ="text"   />
< input  name ="button"  value ="返回"  type ="button"  onclick ="returnWin();"   />
</ form >
</ body >
</ html >
1.html
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312"   />
< title > 无标题文档 </ title >
</ head >
< script >  
function  OpenWin(){
    
var  str = window.showModalDialog( ' 2.html ' ,document.Form1.TextBox1.value, ' help:no ' );
    
if (str != null )  {
        document.Form1.TextBox1.value
= str;
    }
}
</ script >

< body >
< form  name ="Form1" >
< input  name ="TextBox1"  id ="TextBox1"  value ="1"   />
< input  type ="button"  name ="Button1"  value ="打开窗口"  onclick ="OpenWin();"  id ="Button1"  style ="width:96px;"   />
</ form >
</ html >

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值