窗口之间的脚本编程
2013-10-24 10:47
309 查看
以下为openerwindow.htm
以下为newWindow.htm
<html> <head> <script language="JavaScript" type="text/javascript"> var newWindow; function butOpenWin_onclick() { var winTop=(screen.height/2)-125; var winLeft=(screen.width/2)-125; var windowFeatures="width=250,height=250"; windowFeatures=windowFeatures+"left="+winLeft+","; windowFeatures=windowFeatures+"top="+winTop; newWindow=window.open("newWindow.htm","myWindow",windowFeatures); } function butGetText_onclick() { if(typeof(newWindow)=="undefined" || newWindow.closed==true) { alert("No window is open"); } else { document.form1.text1.value=newWindow.document.form1.text1.value; } } function window_onunload() { if(typeof(newWindow)!="undefined" && newWindow.closed==false) { newWindow.close(); } } </script> </head> <body onunload="window_onunload()"> <form name=form1> <input type="button" value="Open newWindow" name=butOpenWin onclick="butOpenWin_onclick()"> <br><br> NewWindow's Text <br> <input type="text" name=text1> <br> <input type="button" value="Get Text" name=butGetText onclick="return butGetText_onclick()"> </form> </body> </html>
以下为newWindow.htm
<html> <head> <script language="JavaScript" type="text/javascript"> function butGetText_onclick() { document.form1.text1.value=window.opener.document.form1.text1.value; } </script> </head> <body> <form name=form1> Opener window's text <br> <input type="text" name=text1> <br> <input type="button" value="Get Text" name=butGetText language="JavaScript" type="text/javascript" onclick="butGetText_onclick()"> </form> </body> </html>
相关文章推荐
- c++选择排序法
- 表单元素值获取方式js及java方式
- Java开闭原则
- PHP正则匹配换行符
- java Array 和 List之间相互转化
- jfreechart 生成报表 (1.0.6)
- javaMail操作
- struts2 s:if 的字符串比较问题
- 文件下载
- JAVA中的集合常用方法介绍
- C#中对输出格式的初始化
- Spring 定时器
- 小记:c++ vector 可能占用大量内存
- 使用Spring框架的12个开源项目
- C# WinForm设置TreeView选中节点
- C++语法一二
- PHP中的几个重要比较
- Java日志管理
- java.lang.NoClassDefFoundError: org/w3c/dom/xpath/XPathEvaluator解决
- Java and C# Comparison