index.html 页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>index</title>
</head>
<frameset border='0' frameborder="no" frameSpacing='0' cols="20%,80%">
<frame name="frame1" id="frame1" src="frame1.html" scrolling='auto' border='0' />
<frame name="frame2" id="frame2" src="frame2.html" scrolling='auto' border='0' />
</frameset>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>frame1</title>
</head>
<body>
<script type="text/javascript">
function methodF2(userName){
//获取父元素(index.html)里的frame2(frame2.html)的对象
var frame2=window.parent.document.getElementById("frame2").contentWindow.document;
//设置frame2.html页面上id为userName的<input/>标签的值
moduleDocument.getElementById("userName").value=userName;
//提交frame2.html页面的form表单
moduleDocument.frm.submit();
}
</script>
<button οnclick="methodF2('张三')">button</button>
</body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>frame2</title>
</head>
<body>
<form action="url" method="post" name="frm" id="frm">
<input type="text" value="" id="userName" name="userName"/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>index</title>
</head>
<frameset border='0' frameborder="no" frameSpacing='0' cols="20%,80%">
<frame name="frame1" id="frame1" src="frame1.html" scrolling='auto' border='0' />
<frame name="frame2" id="frame2" src="frame2.html" scrolling='auto' border='0' />
</frameset>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>frame1</title>
</head>
<body>
<script type="text/javascript">
function methodF2(userName){
//获取父元素(index.html)里的frame2(frame2.html)的对象
var frame2=window.parent.document.getElementById("frame2").contentWindow.document;
//设置frame2.html页面上id为userName的<input/>标签的值
moduleDocument.getElementById("userName").value=userName;
//提交frame2.html页面的form表单
moduleDocument.frm.submit();
}
</script>
<button οnclick="methodF2('张三')">button</button>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>frame2</title>
</head>
<body>
<form action="url" method="post" name="frm" id="frm">
<input type="text" value="" id="userName" name="userName"/>
<input type="submit" value="submit"/>
</form>
</body>
</html>