首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

菜鸟问一个关于创建table的有关问题!firefox可以成功显示,但是IE不行。

2012-10-17 
初学者问一个关于创建table的问题!!firefox可以成功显示,但是IE不行。。。。。。第61行出现错误,就是在newtable.

初学者问一个关于创建table的问题!!firefox可以成功显示,但是IE不行。。。。。。
第61行出现错误,就是在newtable.innerHTML=...的地方。
这个错误在哪呢在哪呢。。

HTML code
<html><meta charset="gbk" /><title>词语关联度查询与投票</title><head><script type="text/javascript">function vote(str){    var xmlhttp1;    var rs=document.getElementById(str);    if (window.XMLHttpRequest)      {    // code for IE7+, Firefox, Chrome, Opera, Safari      xmlhttp1=new XMLHttpRequest();      }    else      {// code for IE6, IE5      xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");      }    xmlhttp1.open("GET","insert.php?query="+str,true);    alert("Succeed!");    rs.innerHTML=parseInt(rs.innerHTML)+1;    xmlhttp1.send(null);    return true;}function found(str){    var query=document.getElementById("word");    var wait=document.getElementById("blank");    wait.innerHTML="Waiting......";    if (str.length==0)    {        wait.innerHTML="";        return true;    };    var xmlhttp;    if (window.XMLHttpRequest)      {    // code for IE7+, Firefox, Chrome, Opera, Safari      xmlhttp=new XMLHttpRequest();      }    else      {// code for IE6, IE5      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");      }    xmlhttp.onreadystatechange=function()    {        //alert(xmlhttp.status);        //alert(xmlhttp.readyState);        if (xmlhttp.readyState==4)        {            if (xmlhttp.status==200) {            wait.innerHTML="";            var words=eval("("+xmlhttp.responseText+")");            var newtable = document.createElement("table");            //下面这句话出了问题,有报错,报错信息详见下方            newtable.innerHTML="<tr><td width = \"100\">ID</td><td width=\"100\">词语1</td><td width = \"100\">词语2</td><td width = \"100\">相关度</td><td width = \"100\">票数</td><td width=\"100\">投票</td></tr>";            for (var i in words)            {                var tr=document.createElement("tr");                var id_td=document.createElement("td");                id_td.innerHTML=words[i].id;                tr.appendChild(id_td);                var word1_td=document.createElement("td");                word1_td.innerHTML=words[i].word1;                tr.appendChild(word1_td);                var word2_td=document.createElement("td");                word2_td.innerHTML=words[i].word2;                tr.appendChild(word2_td);                var relation_td=document.createElement("td");                relation_td.innerHTML=words[i].relation;                tr.appendChild(relation_td);                var number_td=document.createElement("td");                number_td.innerHTML="<div id='"+words[i].id+"'>"+words[i].num+"</div>";                tr.appendChild(number_td);                var vote_td=document.createElement("td");                vote_td.innerHTML="<form> <input type='button'  value='vote' onclick='vote("+words[i].id+")' /> </form>"                tr.appendChild(vote_td);                newtable.appendChild(tr);            }        wait.innerHTML = "";        wait.appendChild(newtable);            }            else {            wait.innerHTML="Connection Failed";}        }    }    xmlhttp.open("GET","search.php?query="+str,true);    xmlhttp.send(null);    return true;}</script> </head><body bgcolor="pink" text="red"><center><h1><b>词汇关系度查询与投票</b></h1><p><form>查询这个词汇:<input id="word" type="text" /><a href='#' onclick="found(document.getElementById('word').value)">搜索</a><p>请输入你想投票的词汇对的id:<input id="votes" type="text" /><a href="#" onclick="vote(document.getElementById('votes').value)">投票</a></form><div id="blank"></div></center></body></html> 



错误提示:

SCRIPT600: 未知的运行时错误 
index.html, 行61 字符13

求助。。
谁来帮忙啊,,

[解决办法]
HTML code
    xmlhttp.onreadystatechange=function()    {        if (xmlhttp.readyState==4)        {            if (xmlhttp.status==200) {            var words=eval("("+xmlhttp.responseText+")");       var newtable = "<table><tr><td width = \"100\">ID</td><td width=\"100\">词语1</td><td width = \"100\">词语2</td><td width = \"100\">相关度</td><td width = \"100\">票数</td><td width=\"100\">投票</td></tr>";            for (var i in words)            {                newtable +="<tr><td>"+words[i].id+"</td><td>"+words[i].word1++"</td><td>"+words[i].word2+"</td><td>"+words[i].relation+"</td><td><div id='"+words[i].id+"'>"+words[i].num+"</div>"+"</td><td><form> <input type='button'  value='vote' onclick='vote("+words[i].id+")' /> </form>"+"</td></tr>";            }        document.getElementById("blank").innerHTML =newtable;            }            else {            document.getElementById("blank").innerHTML="Connection Failed";}        }    }    xmlhttp.open("GET","search.php?query="+str,true);    xmlhttp.send(null);    return true;} 

热点排行