没有基础的我刚接触AJAX,碰到下面的问题,请大家帮忙啊!!!***a.asp**************************
<html>
<head>
<title>---</title>
</head>
<script>
function x() {
var oDiv5 = document.all.m5
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST", "b.asp", false);
xmlhttp.send();
oDiv5.innerHTML = xmlhttp.responseText;
}function y() {
  var divroad1 = document.frames("iframe1").document.getElementById("copy").innerHTML;
.....
}
</script>
<body>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
   <tr>
      <td height="463" id="m5"></td>
   </tr>
   <tr>
      <td height="50"><a href="javascript:;" onClick="x()">第一步</a></td>
   </tr>
   <tr>
      <td height="50"><a href="javascript:;" onClick="y()">第二步</a></td>
   </tr>
</table>
</body>
</html>
***b.asp***************************
<html>
<head>
<title>---</title>
</head>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
   <tr>
      <td height="50">#######<td>
   </tr>
   <tr>
      <td height="50"><iframe id="iframe1" src="c.asp"></iframe></td>
   </tr>
</table>
</body>
</html>
***c.asp***************************
<html>
<head>
<title>---</title>
</head>
<body>
<div id="copy">#####</div>
</body>
</html>运行后b.asp里面的内容正确显示在a.asp里面的表格里.现在的问题来了,当我点击页面中的"第二步"按钮时,我希望能得到那个层的ID:cover.用var divroad1 = document.getElementById("cover").innerHTML时,却取不到这个ID值,结果总是:"对象无此属性或方法"急问怎么解决啊这个问题??

解决方案 »

  1.   

    var divroad1 = document.frames("iframe1").document.getElementById("copy").innerHTML
    var divroad1 = window.frames("iframe1").document.getElementById("copy").innerHTML
    试试吧,不一定对
      

  2.   

    function y() {
      var divroad1 = document.frames("iframe1").document.getElementById("copy").id;
      alert(divroad1);
    }
      

  3.   

    iframe里的c.asp是另一个网页了
      

  4.   

    代码不全看不明白,也不知道你的cover在哪个页面上,你想通过哪个页面去得到。
    cover:如果在第一个页面的话,出现这种情况,可能是页面没有加载完,页面上不存在ID为cover的层。取值为null,调用 innerHTML是会报错。
    ajax取值的页面,不要有html,head等标记,只要有你想要的东西就可以了。b.asp