在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:
相关文档:
在WEB应用中,如果使用jsp作为view层的显示模板,都会被空格/空换行问题所困扰.
这个问题当年也困扰了我比较长的时间.因为在jsp内使用的EL标签和其他标签时,会产生大量的空格和换行符.例如:
------- start ----------
<c:choose>
<c:when test="${fn:length(mainPageList)>1&}&q ......
访问控件的主要对象是:document对象。分别对应当前文档所有的(子对象)个人观点。并且已经提供的几个主要方法来访问对象。
1. document.getElementById
2. document.getElementsByName
3 &n ......
HTML 5——下一代web开发标准
HTML5看来将成为主流,浏览器战争乃至整个互联网的发展也将围绕这一点展开。而Flash、Silverlight和JavaFX等等RIA技术,将面临严峻的生存挑战
参考51cto
http://developer.51cto.com/art/200907/133407.htm ......
百度了下 大体知道 如下区别:
id 代表唯一 ,在整个页面是唯一的,不能重复。
name 可以重复,整个页面的 name 可以都一样
用在JavaScript 中 时
document.getElementById("str") 返回的是 唯一的数据。
document.getElementsByName("str") 返回的是个数组。
还有什么区别?有待路人指证! ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Lan ......