当我点击每一张照片时,我试图让我的照片按顺序出现。当我单击第一个图像时,它会转到第二个图像,但第三个图像却不一样。
主页上的代码:
<script>
function loadXMLDoc()
{
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()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax_info.html",true);
xmlhttp.send();
}
</script>
<div id="myDiv">
<h2><a><button type="submit" onclick="loadXMLDoc()"><img src="/project2_ver3/vor/pic5.jpg" alt="vor" width="540" height="418"/></a></button></h2>
</div>
然后ajax_info.html的代码:
<!DOCTYPE html>
<html>
<body>
<script>
function loadXMLDoc2()
{
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()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDivv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","\project2_ver3\ajax_infoo.html",true);
xmlhttp.send();
}
</script>
<div id="myDivv">
<h2><button type="submit" onclick="loadXMLDoc2()"><img src="/project2_ver3/vor/pic2.jpg" alt="vor" width="540" height="418"/></button></h2>
</div>
</body>
</html>
最后是ajax_infoo.html的代码:
(代码修剪):
xmlhttp.open("GET","ajax_infooo.html",true);
xmlhttp.send();
}
</script>
<div id="myDiv">
<h2><button type="submit" onclick="loadXMLDoc2()"><img src="/project2_ver3/vor/pic1.jpg" alt="vor" width="540" height="418"/></button></h2>
</div>
</body>
</html>