我正在创建一个基于 AJAX 的详细信息系统,其中详细信息在onmouseover事件中可见,为此我创建了以下 HTML 以显示
<html>
<head>
<Script src="scripts/ajaxfunctions.js"></Script>
</head>
<body>
<table widht="1000">
<tbody>
<tr>
<td width="500">
<img src="Images/0.jpg" width="100" height="100" onmouseover="func(0)" onmouseout="clear()" />
</td>
<td rowspan="8" width="500">
<div id="myDiv" ></div>
</td>
<tr>
<td width="500">
<img src="Images/1.jpg" width="100" height="100" onmouseover="func(1)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/2.jpg" width="100" height="100" onmouseover="func(2)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/3.jpg" width="100" height="100" onmouseover="func(3)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/4.jpg" width="100" height="100" onmouseover="func(4)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/5.jpg" width="100" height="100" onmouseover="func(5)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/6.jpg" width="100" height="100" onmouseover="func(6)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/7.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/8.jpg" width="100" height="100" onmouseover="func(8)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/9.jpg" width="100" height="100" onmouseover="func(9)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/10.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr><tr>
<td width="500">
<img src="Images/11.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/12.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/13.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/14.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/15.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/16.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr><tr>
<td width="500">
<img src="Images/17.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/18.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/19.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr><tr>
<td width="500">
<img src="Images/20.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr><tr>
<td width="500">
<img src="Images/21.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr><tr>
<td width="500">
<img src="Images/22.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr><tr>
<td width="500">
<img src="Images/23.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr><tr>
<td width="500">
<img src="Images/24.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/24.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/25.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
<tr>
<td width="500">
<img src="Images/26.jpg" width="100" height="100" onmouseover="func(7)" onmouseout="clear()" />
</td>
</tr>
</tbody>
</table>
</body>
</html>
在这里,详细信息将显示在 div 标签中....但是当左侧的条目展开时,DIV 标签中的内容不可见...向上滚动以查看详细信息...有什么办法可以修复右侧的 div 进入屏幕?
Javascript代码在这里
function func(num)
{
var xmlhttp;
var txt,x,xx,i;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{ // code for IE6, IE5
xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
txt="";
try
{
var xmlDoc=xmlhttp.responseXML;
txt="";
var a = 0;
x=xmlDoc.getElementsByTagName("Person");
var xx= x[num].getElementsByTagName("Name");
txt += "Name : " + xx[0].firstChild.nodeValue+ "<br>" ;
xx = x[num].getElementsByTagName("RegistrationNO");
txt += "RegistrationNo : " + xx[0].firstChild.nodeValue+ "<br>" ;
xx = x[num].getElementsByTagName("Address");
txt += "Address : " + xx[0].firstChild.nodeValue+ "<br>" ;
xx= x[num].getElementsByTagName("ContactNo");
txt += "Contact No : " + xx[0].firstChild.nodeValue+ "<br>";
document.getElementById("myDiv").innerHTML=txt;
}
catch (er)
{
document.getElementById('myDiv').innerHTML=er+" 1";
}
}
}
try
{
xmlhttp.open("GET","http://localhost/StudentDetails/Data/database.xml",true);
xmlhttp.send();
}
catch (er)
{
document.getElementById('myDiv').innerHTML=er+" 2";
}
}