查看完整版本: 新手提问,关于getElementById

虚心求教 2007-5-9 21:37

新手提问,关于getElementById

新手提问,关于getElementById


没有基础的我刚接触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 = [b][color=red]document.frames("iframe1").document.getElementById("copy").innerHTML[/color][/b];
.....
}
</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:;" >第一步</a></td>
   </tr>
   <tr>
      <td height="50"><a href="javascript:;" >第二步</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 = [b][color=#ff0000]document.frames("iframe1").document.getElementById("copy").innerHTML[/color][/b]时,却取不到这个ID值,结果总是:"对象无此属性或方法"
急问怎么解决啊这个问题??

Test 2007-5-10 09:08

你找找 "<iframe id="iframe1" src="c.asp"></iframe> 这段中的c.asp 文件中是否有ID=“copy”的对象。
页: [1]

查看完整版本: 新手提问,关于getElementById