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 父窗口与子窗口交互的更多相关文章

  1. JS实现关闭当前子窗口,刷新父窗口

    一.JS实现关闭当前子窗口,刷新父窗口 JS代码如下: <script> function refreshParent() {  window.opener.location.href = ...

  2. js window.open() 父窗口与子窗口的互相调用(未必有用)

    javascript 父窗口与子窗口的互相调用 <html> <head></head> <body> 主要实现父子关系的页面 window.opene ...

  3. #js window.open() 父窗口与子窗口的互相调用【转】

    未完整版 javascript 父窗口与子窗口的互相调用 a.html 父页面 <HTML> <HEAD> <meta http-equiv="content- ...

  4. 总结js(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作

    http://hi.baidu.com/yashua839/blog/item/131fdb2fe547ef221f3089af.html一.Iframe 篇 //&&&&am ...

  5. JS实现关闭当前子窗口,刷新父窗口及调用父窗口的方法

    一.js实现关闭当前子窗口,刷新父窗口 JS代码如下: <script> function refreshParent() {  window.opener.location.href = ...

  6. HTML中IFrame父窗口与子窗口相互操作

    一.Iframe篇 //&&&&&&&&&&&&&&&&&&am ...

  7. JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作

    一.Iframe 篇 公共部分 //父对象得到子窗口的值 //ObjectID是窗口标识,ContentID是元素ID function GetValue(ObjectID,ContentID) { ...

  8. 总结JavaScript(Iframe、window.open、window.showModalDialog)父窗口与子窗口之间的操作

    一.Iframe 篇 //&&&&&&&&&&&&&&&&&&a ...

  9. iframe父窗口和子窗口之间的调用

    1>父窗口获取子窗口 js方法 document.getElementById('if1').contentWindow.document: window.frames["if1&qu ...

  10. windows窗口分析,父窗口,子窗口,所有者窗口

    (本文尝试通过一些简单的实验,来分析Windows的窗口机制,并对微软的设计理由进行一定的猜测,需要读者具备C++.Windows编程及MFC经验,还得有一定动手能力.文中可能出现一些术语不统一的现象 ...

随机推荐

  1. [Codeforces #210] Tutorial

    Link: Codeforces #210 传送门 A: 贪心,对每个值都取最大值,不会有其他解使答案变优 #include <bits/stdc++.h> using namespace ...

  2. [HDU3756]Dome of Circus

    题目大意: 在一个立体的空间内有n个点(x,y,z),满足z>=0. 现在要你放一个体积尽量小的圆锥,把这些点都包住. 求圆锥的高和底面半径. 思路: 因为圆锥里面是对称的,因此问题很容易可以转 ...

  3. Problem D: 零起点学算法95——弓型矩阵

    #include<stdio.h> #include<string.h> int main() { ][]; while(scanf("%d%d",& ...

  4. mysql函数的使用create function myfunction(...

    use test   //必须在某个数据库下面创建 delimiter $ //创建 CREATE FUNCTION myFunction(ln int, ls int)   //参数这里不能加def ...

  5. [转]Syntax error on token "Invalid Character", delete this token 的解决

    原文  http://blog.csdn.net/actsai/article/details/24256987 主题 Eclipse Unicode Java eclipse 中遇到了Syntax ...

  6. LRU近期最少使用算法

    LRU(least recently used)最少使用. 假设 序列为 4 3 4 2 3 1 4 2 物理块有3个 则 首轮 4调入内存 4 次轮 3调入内存 3 4 之后 4调入内存 4 3 之 ...

  7. POJ 2019 Cornfields (二维RMQ)

    Cornfields Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 4911   Accepted: 2392 Descri ...

  8. mysql join优化

    http://www.jb51.net/article/50427.htm 七.性能优化1.显示(explicit) inner join VS 隐式(implicit) inner join 如: ...

  9. JSON Bean 相互转换工具(效率是Gson的两倍以上)

    本帖最后由 xuehuayous 于 2015-12-24 08:44 编辑 前几天想封装一个自定义控件,用到Json解析,以前都使用Gson来解析Json数据的,但是想到一个简单的自定义控件就没必要 ...

  10. ImageWriter制作ubuntu的U盘启动盘

    转自:http://my.oschina.net/f839903061/blog/197935?p={{currentPage+1}} 1.工具从ubuntn中文网中下载指定软件:ImageWrite ...