日期:2014-05-16  浏览次数:20439 次

不同html页面传值问题 [javaScript]
小弟遇到一个问题:
有两个html页面文件: a.html和b.html ,如果我点击a.html上面的确定按钮,将获取a.html里表格的值,并且传递到b.html页面上的表格内(同步显示出来), 并且不断点击a.html里的确定按钮,会不断添加内容到b.html的表格里,将如何实现? 各位请大侠指点迷津

------解决方案--------------------
试试IFRAME吧.
看看这个
http://blog.csdn.net/theforever/article/details/6126635
------解决方案--------------------
c.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>
</head>

<frameset cols="50%,50%">
<frame src="a.html">
<frame src="b.html">
</frameset>
</html>

a.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 type="text/javascript">
function show(){
var a=document.getElementById("test").value;
var p=window.parent.frames[1];
var tr=document.createElement("tr");
var td=document.createElement("td");
td.innerHTML=a;
tr.appendChild(td);
p.document.getElementById("test").appendChild(tr);
}
</script>
</head>

<body>
<input type="text" id="test">
<input type="button" onclick="show()" value="add">
</body>
</html>


b.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>
</head>

<body>
<table id="test"></table>
</body>
</html>
  

用iframe或frameset试试