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经验,还得有一定动手能力.文中可能出现一些术语不统一的现象 ...
随机推荐
- luogu P1016 旅行家的预算
题目描述 一个旅行家想驾驶汽车以最少的费用从一个城市到另一个城市(假设出发时油箱是空的).给定两个城市之间的距离D1.汽车油箱的容量C(以升为单位).每升汽油能行驶的距离D2.出发点每升汽油价格P和沿 ...
- 扫描线三巨头 hdu1928&&hdu 1255 && hdu 1542 [POJ 1151]
学习链接:http://blog.csdn.net/lwt36/article/details/48908031 学习扫描线主要学习的是一种扫描的思想,后期可以求解很多问题. 扫描线求矩形周长并 hd ...
- Problem E: 12306
#include <stdio.h> struct student{ int n; int m;}; int main(void) { int T; int k,g,i,j; ],max; ...
- RSA加密破解
1Linux 下安装gmpy2 https://www.cnblogs.com/ESHLkangi/p/8576113.html 2.yafu安装使用方法 https://www.cnblogs.co ...
- javascript实现原生ajax
自从javascript有了各种框架之后,比如jquery,使用ajax已经变的相当简单了.但有时候为了追求简洁,可能项目中不需要加载jquery这种庞大的js插件.但又要使用到ajax这种功能该如何 ...
- Oracle Extended Tracing
Definitions A trace file is a file that contains diagnostic data used to investigate problems. Als ...
- sql server的sql 语句中的列名包含[]时候,把]替换成]]就可以
sql server的sql 语句中的列名包含[]时候,把]替换成]]就可以eg: create table p.e_LOG_WebServer ( [BSCFlg] int, ), ) ); sel ...
- PostgreSQL配置文件--QUERY TUNING
5 QUERY TUNING 5.1 Planner Method Configuration. 下列参数控制查询优化器是否使用特定的存取方法.除非对优化器特别了解,一般情况下,使用它们默认值即可. ...
- Boost::Lexical_cast 的使用
.C++代码 #include <boost/lexical_cast.hpp> #include <iostream> int main() { using boost::l ...
- MLP 之手写数字识别
0. 前言 前面我们利用 LR 模型实现了手写数字识别,但是效果并不好(不到 93% 的正确率). LR 模型从本质上来说还只是一个线性的分类器,只不过在线性变化之后加入了非线性单调递增 sigmoi ...