js 父窗口与子窗口交互
showModalDialog
父窗口
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>a.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<script language="JavaScript"> </script> <body>
<form name="form1" action="test.html" method="post" >
客户id: <input type="text" name="cid" value="" id="cid" ><br>
客户名称<input type="text" name="cname" value="" id="cname" >
<input type="button" name="ok" value="请选择客户" onclick="openWin();"/>
</form>
<script type="text/javascript">
function openWin(){
/*
* vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
* 参数:
* sURL:要打开的窗口的页面。可以使用绝对路径,也可以使用相对路径
* vArguments:给sURL那个页面的窗口传递参数。
* sFeatures:控制打开的sURL那个页面的窗口的样式
*/
window.showModalDialog("a2.html",window,"help:no;status:no;dialogHeight:150px;dialogWidth:220px");
}
function setValue(cid,cname){
document.getElementById("cid").value = cid;
document.getElementById("cname").value = cname;
}
</script>
</body> </html>
子窗口
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>a2.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<script language="JavaScript">
</script>
<body>
<table border="1">
<tr>
<td>操作</td>
<td>客户id</td>
<td>客户名称</td>
</tr> <tr>
<td><input type="button" value="选择" id="ss" onclick="viewData('001','深圳华为')"></td>
<td>001</td>
<td>深圳华为</td>
</tr>
<tr>
<td><input type="button" value="选择" onclick="viewData('002','用友软件')"> </td>
<td>002</td>
<td>用友软件</td>
</tr>
</table>
<script type="text/javascript">
function viewData(pid,pname){
//如何得到之前的那个窗口对象
var parentWindow = window.dialogArguments;
parentWindow.setValue(pid,pname);
window.close();
} </script>
</body> </html>
open
父窗口
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>a.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<script language="JavaScript"> </script> <body>
<form name="form1" action="test.html" method="post" >
<select edu="edu" id="edu">
<option value="本科">本科</option>
</select>
<input type="button" name="ok" value="添加" onclick="openWin();"/>
</form>
<script type="text/javascript">
function openWin(){
window.open("a2.html","_blank");
}
//增加option元素
function setValue(name){
//创建option
var optionElement = document.createElement("option");//<option></option>
//设置属性和内置文本
optionElement.setAttribute("value",name);
var textNode = document.createTextNode(name);
optionElement.appendChild(textNode);
//挂接到select上即可
document.getElementById("edu").appendChild(optionElement);
}
</script>
</body> </html>
子窗口
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>a2.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<table border="1"> <tr>
<td><input type="text" name="eduname" id="eduname" value="" size=8></td>
<td><input type="button" name="ok" value="确定" onclick="setData();"></td>
</tr> </table>
<script type="text/javascript">
function setData(){
var eduName = document.getElementById("eduname").value;
//得到父窗口
var parentWindow = window.opener;
parentWindow.setValue(eduName);
window.close();
} </script>
</body> </html>
js 父窗口与子窗口交互的更多相关文章
- JS实现关闭当前子窗口,刷新父窗口
一.JS实现关闭当前子窗口,刷新父窗口 JS代码如下: <script> function refreshParent() { window.opener.location.href = ...
- js window.open() 父窗口与子窗口的互相调用(未必有用)
javascript 父窗口与子窗口的互相调用 <html> <head></head> <body> 主要实现父子关系的页面 window.opene ...
- #js window.open() 父窗口与子窗口的互相调用【转】
未完整版 javascript 父窗口与子窗口的互相调用 a.html 父页面 <HTML> <HEAD> <meta http-equiv="content- ...
- 总结js(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
http://hi.baidu.com/yashua839/blog/item/131fdb2fe547ef221f3089af.html一.Iframe 篇 //&&&&am ...
- JS实现关闭当前子窗口,刷新父窗口及调用父窗口的方法
一.js实现关闭当前子窗口,刷新父窗口 JS代码如下: <script> function refreshParent() { window.opener.location.href = ...
- HTML中IFrame父窗口与子窗口相互操作
一.Iframe篇 //&&&&&&&&&&&&&&&&&&am ...
- JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
一.Iframe 篇 公共部分 //父对象得到子窗口的值 //ObjectID是窗口标识,ContentID是元素ID function GetValue(ObjectID,ContentID) { ...
- 总结JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作
一.Iframe 篇 //&&&&&&&&&&&&&&&&&&a ...
- iframe父窗口和子窗口之间的调用
1>父窗口获取子窗口 js方法 document.getElementById('if1').contentWindow.document: window.frames["if1&qu ...
- windows窗口分析,父窗口,子窗口,所有者窗口
(本文尝试通过一些简单的实验,来分析Windows的窗口机制,并对微软的设计理由进行一定的猜测,需要读者具备C++.Windows编程及MFC经验,还得有一定动手能力.文中可能出现一些术语不统一的现象 ...
随机推荐
- [USACO 2017 Jan Gold] Tutorial
Link: 传送门 A: 按值大小插入后用树状数组统计两边个数 #include <bits/stdc++.h> using namespace std; #define X first ...
- [LOJ2553]暴力写挂
锟题x2 以下用$a\rightarrow b$表示端点为$a,b$的链 把式子写成$(h_1(x)+h_1(y)-h_1(lca))-h_2(lca')$,第一部分就是$x\rightarrow r ...
- 【后缀自动机】poj1509 Glass Beads
字符串最小表示 后缀自动机 O(n) 把串复制一次,链接在后面之后,建立SAM,贪心地在SAM上转移,每次贪心地选择最小的字符,转移的长度为n时停止. 输出时由于要最靠前的,所以要在endpos集合中 ...
- 数据库之mysql的基本操作
1 数据库 1.1 数据库介绍 为什么要有数据库? 数据需要大量的存储,把数据永久保存下来,可以保存到文件中,当然也可以保存到数据库中. 数据库:通俗的说,存储数据的仓库,是管理数据的文件夹:存放数据 ...
- 你一定喜欢看的 Webpack 2.× 入门实战(转载)
最近在学习 Webpack,网上大多数入门教程都是基于 Webpack 1.x 版本的,我学习 Webpack 的时候是看了 zhangwang 的 <<入门 Webpack,看这篇就够了 ...
- [转载]memcached 命令操作详解
转载:http://www.cnblogs.com/azheng007/p/3159345.html 一.存储命令 存储命令的格式: <command name> <key> ...
- HMACSHA1算法的JAVA实现
import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; publ ...
- Maven:程序包org.apache.log4j不存在问题处理
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> & ...
- redis节点管理-新增从节点
原文:http://blog.sina.com.cn/s/blog_53b45c4d0102wg12.html 新增从节点 新增一个节点7008节点,使用add-node --slave命令. [pl ...
- FIREMONEY手机虚拟键盘遮挡的解决
FIREMONEY手机虚拟键盘遮挡的解决 尝遍了网上人们提供的N种方法之后,发现还是老猫的方法才是彻底解决问题的办法. 老猫“不看后悔XXX”--->RAD10.2.3 Flying Wang ...