在html web网页中父子窗口之间值的传值
在Web开发中,常常要用到两个窗口之间互相传值。下面谈谈父子窗口之间的传值:
一:使用Open开启子窗口
1:单值传递
通过open开启的子窗口比较好处理。
页面窗口1.html代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<body>
<form name="dForm" id="dForm" method="post" onsubmit="return dFormCK();" action="abc.php">
<input type="text" size="30" name="p" id="p" value=""/>
</form>
<a href="javascript:void(0)" onclick="window.open('2.html','child','width=400,height=300,left=200,top=200');">打开子窗口</a>
</body>
</html>
Open后弹出的子窗口2.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<base target="_self">
<body>
<input type="button" onclick="JavaScript:window.opener.document.getElementById('p').value='ok';window.close();" value="确定">
</body>
2:多值传递
多值的值的传递与单值传递是一模一样的。
页面窗口1.html代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<body>
<form name="dForm" id="dForm" method="post" onsubmit="return dFormCK();" action="abc.php">
<input type="text" size="30" name="p0" id="p0" value=""/><br />
<input type="text" size="30" name="p1" id="p1" value=""/>
</form>
<a href="javascript:void(0)" onclick="window.open('2.html','child','width=400,height=300,left=200,top=200');">打开子窗口</a>
</body>
</html>
Open后弹出的子窗口2.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<base target="_self">
<body>
<input type="button" onclick="JavaScript:window.opener.document.getElementById('p0').value='值一';window.opener.document.getElementById('p1').value='值二';window.close();" value="确定">
</body>
二:使用showModalDialog开启子窗口
1:
相关文档:
转载:http://jiangzhengjun.javaeye.com/blog/480996
事件
DOM同时支持两种事件模式:捕获型事件和冒泡型事件,但是,捕获型事件先发生。两种事件流会触及DOM中的所有对象,从document对象开
始,也在document对象结束(大部分兼容标准的浏览会继续将事件捕获/冒泡延续至window对象),DOM中的元素都会连续收到两次事 ......
方式一: 或 作换行符
方式二:直接在源码中敲回车
【建议】 采用方案一。
【源码】
<a href="#" title="第一行 第二行 第三行">方式一:鼠标放在我上面看一下title</a>
<br />
<br />
<a href="#" title="第一行
第二行
第三行">方式二:鼠� ......
百度了下 大体知道 如下区别:
id 代表唯一 ,在整个页面是唯一的,不能重复。
name 可以重复,整个页面的 name 可以都一样
用在JavaScript 中 时
document.getElementById("str") 返回的是 唯一的数据。
document.getElementsByName("str") 返回的是个数组。
还有什么区别?有待路人指证! ......
鼠标的多种样式...
<P><a href="help.htm" style="cursor:hand">手</a>
<a href="help.htm" style="cursor:text">文本</a>
<a href="help.htm" style="cursor:MOVE">四个方向的箭头</a>
<a href="help.htm" st ......