模态窗体

<!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>
    <title>通过模特窗口传值</title>
    <script language="javascript" type="text/javascript">
        <!--
        function Button1_onclick()
        {
            //打开一个新的窗口
            str1=document.forms[0].sname.value;
            str1=window.showModalDialog("jsd15_1.html",str1,"dialogTop:100px;dialogLeft:300px;dialogHeight:200px;dialogWidth:300px");
            document.forms[0].sname.value=str1;
        }
        // -->
    </script>
</head>
<body>
    <form>
        姓名:<input type="text" name="sname" value="" /><br />
        <br />
        <input type="button" value="打开一个模特窗口并传值" name="but1" id="Button1" language="javascript"
            onclick="Button1_onclick();" />&nbsp;
        <br />
        <br />
       
    </form>
</body>
</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>
    <title>使用window.open打开的新窗口</title>
    <base target="_self"></base>
    <script language="javascript">
        //得到父窗体的值(通过窗体的onLoad事件)
        function getParentValue()
        {
            document.forms[0].sname.value=window.dialogArguments; //得到模特窗口传进来的值
            //var win1=window.dialogArguments;
            //document.forms[0].sname.value=win1.document.forms[0].sname.value;
        }
       
        //将修改后的值传回到原来的窗口
        function Button1_onclick()
        {
            window.returnValue= document.forms[0].sname.value;
            window.close();
        }
    </script>
</head>
<body onload="javascript:getParentValue();">
    <form>
        姓名:<input type="text" name="sname" value="" />
        <br />
        <br />
        <input type="button" value="关闭返回" name="but1" id="Button1" language="javascript"
            onclick="Button1_onclick();" />
           
         <br />
         <a href="jsd15_1.html">打开一个链接</a>
    </form>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值