悬赏园豆:15
[已解决问题]
解决于 2008-08-26 13:56
<P>function createXMLHttpRequest() { <BR> if (window.ActiveXObject) { <BR> xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); <BR> } <BR> else if (window.XMLHttpRequest) { <BR> xmlHttp = new XMLHttpRequest(); <BR> } <BR>} <BR>function getimg() { <BR> <BR> <BR> var url = "puzzle_do.jsp" ; <BR> createXMLHttpRequest(); <BR> xmlHttp.open("POST", url, true); <BR> xmlHttp.onreadystatechange = handleStateChange; <BR> xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); <BR> xmlHttp.send(); <BR>} <BR>function handleStateChange() { <BR> if(xmlHttp.readyState == 4) { <BR> if(xmlHttp.status == 200) { <BR> window.setTimeout(getimg,1000); <BR> var srcs=xmlHttp.responseText.substring(6,xmlHttp.responseText.length);<BR> // alert(srcs);<BR> fillimg(srcs);<BR> } <BR> } <BR>} </P>
<P> <BR> function fillimg(srcs){<BR> var index=0;<BR> //var srcs="F:/1_1.jpg,F:/1_2.jpg,F:/1_3.jpg,F:/2_1.jpg,F:/2_2.jpg,F:/2_3.jpg,F:/3_1.jpg,F:/3_2.jpg,F:/3_3.jpg,#";<BR> var src=srcs; <BR> //alert("in");<BR> var list =src.split(','); <BR> //alert(list[0]); <BR> //alert("write");<BR> document.getElementById("img").innerHTML+="<table border='1px'><br>";</P>
<P> for (var r=0;r<4;r++)<BR> {<BR> // alert("for1start");<BR> <BR> document.getElementById("img").innerHTML+="<tr><br>";<BR> if(r<3)<BR> {<BR> for (var d=0;d<3;d++)<BR> {<BR> //alert("for2start");<BR> if(list[index]!=null&&list[index]!=""&&list[index]!="&nbsp;")<BR> {<BR> // alert(list[index]);<BR> document.getElementById("img").innerHTML+="<td><img src=\'"+list[index] + "\' alt=\'\' width=70px height=70px\/></td>&nbsp;&nbsp;";<BR> index++;<BR> }<BR> else<BR> {<BR> // alert(list[index]);<BR> document.getElementById("img").innerHTML+="<td><img src=\'"+list[index] + "\' alt=\'\' width=70px height=70px\/></td>&nbsp;&nbsp;";<BR> index++;<BR> }<BR> }<BR> document.getElementById("img").innerHTML+="<br></tr>"; <BR> }<BR> else<BR> {<BR> //alter(list[index]);<BR> document.getElementById("img").innerHTML+="<td><img src=\'"+list[index] + "\' alt=\'\' width=70px height=70px\/></td>&nbsp;&nbsp;";<BR> document.getElementById("img").innerHTML+="<br></tr>";<BR> <BR> //alert(index);<BR> //alert(list[index]);<BR> }<BR> {<BR> <BR> <BR> }<BR> document.getElementById("img").innerHTML+="<br></tr>"; <BR> }<BR> document.getElementById("img").innerHTML+="<tr><td colspan=\'3\'><img name=\'img_sure\' src=\'C:/Documents and Settings/dgtdg/My Documents/My Pictures/091715_1681792287_qqodzhdb.jpg\' height=\'210px\' width=\'210px\'\/></td></tr><br>";<BR> document.getElementById("img").innerHTML+="</table>";</P>
<P> }<BR>由于自定刷新,而且document.getElementById("img").innerHTML+= 导致每次刷新后,在原先的基础上又继续写下去了,页面无限扩大,请问下怎么解决好啊</P>