当前位置:首页文章首页 IT学院 IT技术

动态窗口中子页面向父页面传递值

作者:  来源:  发布时间:2012-2-17 17:14:09  点击:

题目:在父页面中,点击“编辑”链接,跳至子页面中进行编辑,编辑完成后点击“确定”,子页面关闭,将编辑内容回传至父页面。

原理:在父页面中,点击“编辑”时,设置一个变量,此变量用于打开子页面新窗口,也用于接收子页面的返回值;在子页面中,设置一个函数,完成返回传递值和关闭窗口的工作。

父页面代码:

<body>

 <a href="#" s= window.showModalDialog('b.html');s_Context1.innerHTML = s">编辑</a>

</body>

 

子页面代码:

<body>

<div id="edit-text">
            <form id="search" method="get">
            <!--action="/search.php"-->
            <input type="text" id="txt_Context" name="firstname" style="width: 640px; height: 400px;" />
            <input type="button" value="确定" style="margin-left: 300px;" onclick="ReturnValue(txt_Context.value)" />
            </form>
</div>

</body>

 

<script type="text/javascript">
        function ReturnValue(a) {
            window.returnValue = a;
            window.close();
        }

</script>

 

上一篇:Linux中的文件系统 下一篇:

相关软件

相关文章

文章评论

软件按字母排列: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z