//模式窗体传值
<!-- ======
父窗体,我取名为parentform.html ====
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>弹出窗口内录入数据确定后返回给父窗体--主窗体</title>
<META NAME="Generator"
CONTENT="EditPlus">
<META NAME="Author"
CONTENT="qiujy">
<META NAME="Keywords"
CONTENT="">
<META NAME="Description"
CONTENT="">
<script language="javascript"
type="text/javascript">
function doInput()
{
var win =
window.showModalDialog("Childform.html",window,"dialogWidth=500px;dialogHeight=300px;center=yes;status=no");
if(win != null)
{
document.getElementById("parentTextBox").value =
win;
}
}
</script>
</head>
<body>在新弹出的窗体里输入数据,传输到父窗体.
<br/>
<br/>
<br/>
<input
type="text" id="parentTextBox" /> <a
href="javascript:doInput()">点这里弹出子窗体</a>
</BODY>
</HTML>
<!--
============= 父窗体代码结束 =============
-->
<!-- ======= 子窗体:取名为childform.html =======
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>
弹出窗口内录入数据确定后返回给父窗体--子窗体</title>
<META NAME="Generator"
CONTENT="EditPlus">
<META NAME="Author"
CONTENT="qiujy">
<META NAME="Keywords"
CONTENT="">
<META NAME="Description"
CONTENT="">
<base target="_self">
</head>
<body topmargin="0" leftmargin="0"
scroll="no">
</br>
<input
type="text" id="childTextBox"/>
</br></br>
<a
href="javascript:doPassToParent()">点这里返回</a>
</BODY>
</HTML>
<script language="javascript"
type="text/javascript">
document.getElementById("childTextBox").value =
window.dialogArguments.document.getElementById("parentTextBox").value;
function doPassToParent()
{
if(document.getElementById("childTextBox").value.length
<=0)
{
alert("请填写数据");
return;
}
window.returnValue =
document.getElementById("childTextBox").value;
window.close();
}
</script>
//子窗体和父窗体传值
1.新建两个页面 一个是 Parent.html
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>父窗体</title>
<script language="javascript"
type="text/javascript">
function OpenWindow(){
window.open('son.html');
}
function setValue(m_strValue){
document.getElementById("txt_Value").value = m_strValue;
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post"
action="">
<label>
<input type="text"
name="txt_Value" id="txt_Value" />
</label>
<label>
<input type="button"
name="btn_ShowClose" id="btn_ShowClose" value="按钮"
onclick="OpenWindow();" />
</label>
</form>
</body>
</html>
另一个是子窗体 :
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>子窗体</title>
<script language="javascript" type="text/javascript"
>
function CloseWind(){
opener.setValue("传值到父窗体");
window.close();
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post"
action="">
<label>关闭
<input type="button"
name="btn_Close" id="btn_Close" value="按钮"
onclick="CloseWind();"
/>
</label>
</form>
</body>
</html>
2.通过子窗体执行的父窗体的setValue(m_strValue)来执行赋值操作.
相关推荐
javascript 子窗体父窗体相互传值方法,一般都是用window.open函数,下面脚本之家给出具体的代码。
通过js实现的子窗体与父窗体之间的值传递
NULL 博文链接:https://phpxiaoxin.iteye.com/blog/423340
目录 概述一、父组件向子组件传值二、子组件向父组件传值1.子组件绑定一个事件,通过 this.$emit() 来触发2.通过 callback 函数3. 通过 $parent / $children 或 $refs 访问组件实例三、兄弟组件之间传值1. 还是...
frame与frame之间如何用JavaScript传值
本篇文章主要是对javascript 实现子父窗体互相传值的简单实例进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助
主要介绍了JavaScript实现在页面间传值的方法,涉及javascript传值的技巧,非常具有实用价值,需要的朋友可以参考下
此资源为 swift 与JavaScript 之间方法的相互调用,相互传值。
主要介绍了JavaScript实现弹出子窗口并传值给父窗口,方法很简单,这里推荐给大家,需要的朋友可以参考下
Javascript 两个窗体之间传值实现代码javascript中还有一个函数window.showModalDialog也可以打开一个新窗体,不过他打开的是一个模态窗口,那么如何在父窗体和子窗体之间传值呢?我们先看该函数的定义:...
众所周知window.open() 函数可以用来打开一个新窗口,那么如何在子窗体中向父窗体传值呢,其实通过window.opener即可获取父窗体的引用。
有两种方式 第一种:对于用window.open()方法打开的页面 第二种:用window.showModalDialog()
很多时候都要用jsp利用session进行传值 现在静态网页也可以进行同样的操作。希望能帮到大家。
javascript的页面传值。值得下载!
javascript静态页面传值的三种方法 带例子
javascript 滚动窗体 弹出窗体 自动隐藏窗体 可拖动窗体
javascript弹出窗体
本文实例讲述了jQuery子窗体取得父窗体元素的方法。分享给大家供大家参考。具体如下: $(#父窗口元素ID,window.parent.document); 对应javascript版本为 window.parent.document.getElementById(父窗口元素ID); 取...
javascript 两个页面之间传值 使用window.open()