js子级窗口向父级窗口传值
<!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">
var a = window.open("b.php","_blank","width=200 height=200 toolbar=no"); //在新窗口打开b.php //window.setTimeout("ccc()",3000); function ccc()
{
a.close();
}
</script>
</head> <body>
<div id="dd"></div>
</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">
function dodo()
{
//取出值
var s = document.getElementById("t1").value; //给父窗口
var dd = window.opener.document.getElementById("dd"); //opener打开父级窗口
dd.innerHTML = s;
}
</script>
</head> <body>
<form>
<input type="text" id="t1" name="t1">
<input type="button" value="点击给父窗口" onclick="dodo()">
</form>
</body>
</html>
js一次打开或关闭多个窗口
<!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"> var arr = new Array();
function doopen()
{
for(var i=1;i<=5;i++)
{
arr[i-1] = window.open("b.php","_blank","width=200 height=100 toolbar=no");
}
}
function doclose()
{
for(var i=0;i<arr.length;i++)
{
arr[i].close();
}
} </script>
</head> <body>
<div id="dd"></div>
<span onClick="doopen()">打开5个子窗口</span>
<span onclick="doclose()">关闭5个子窗口</span> </body>
</html>
window.location.href="..."; 跳转页面
window.location.reload(); 刷新页面
document.getElementById(); 根据id找
document.getElementsByName(); 根据name找
document.getElementsByClassName(); 根据class找
document.getElementsByTagName(); 根据标签找
getAttribute() 获取属性
setAttribute() 赋予属性
removeAttribute() 移除属性
表单元素 value
非表单元素 innerHTML innerText