我改进了一下,先放置几个隐藏的层,然后当鼠标移到超链接的位置时,计算要显示层的单元格的坐标,然后设置给层显示,这在ie里好用,但在firefox里无效,可以得到单元格的坐标,但layer.style.left=x;这种写法不对,请问谁有解决办法?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head><body><div id="lay1" style="position:absolute; left:82px; top:221px; width:237px; height:140px; z-index:1; background-color: #999999; layer-background-color: #999999; border: 1px none #000000; ">此处显示
id "div1" 的内容<br>
此处显示 id "div1" 的内容<br>
此处显示 id "div1" 的内容<br>
此处显示 id "div1" 的内容</div>
<script type="text/javascript">
function showmenu(elem_id)
{
var elem= document.getElementById(elem_id);
var x=elem.offsetLeft;
var y=elem.offsetTop;
alert("x="+x+",y="+y);
var layer=document.getElementById("lay1");
layer.style.left=x;
layer.style.top=y;
layer.style.display="block";
}
function hide()
{
document.getElementById("lay1").style.display="none";
}
</script>
<table width="33%" border="0">
<tr>
<td width="10%">111</td>
<td width="45%"><div onMouseOver="showmenu('td1')">超链接题目</div></td>
<td width="45%" onMouseOver="showmenu('td2')">超链接2 </td>
</tr>
<tr>
<td>111</td>
<td id="td1"></td>
<td id="td2"></td>
</tr>
<tr>
<td>111</td>
<td>222</td>
<td> </td>
</tr>
</table>
<p> </p>
</body>
</html>现在js版块人气怎么这么差呀
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head><body><div id="lay1" style="position:absolute; left:82px; top:221px; width:237px; height:140px; z-index:1; background-color: #999999; layer-background-color: #999999; border: 1px none #000000; ">此处显示
id "div1" 的内容<br>
此处显示 id "div1" 的内容<br>
此处显示 id "div1" 的内容<br>
此处显示 id "div1" 的内容</div>
<script type="text/javascript">
function showmenu(elem_id)
{
var elem= document.getElementById(elem_id);
var x=elem.offsetLeft;
var y=elem.offsetTop;
alert("x="+x+",y="+y);
var layer=document.getElementById("lay1");
layer.style.left=x;
layer.style.top=y;
layer.style.display="block";
}
function hide()
{
document.getElementById("lay1").style.display="none";
}
</script>
<table width="33%" border="0">
<tr>
<td width="10%">111</td>
<td width="45%"><div onMouseOver="showmenu('td1')">超链接题目</div></td>
<td width="45%" onMouseOver="showmenu('td2')">超链接2 </td>
</tr>
<tr>
<td>111</td>
<td id="td1"></td>
<td id="td2"></td>
</tr>
<tr>
<td>111</td>
<td>222</td>
<td> </td>
</tr>
</table>
<p> </p>
</body>
</html>现在js版块人气怎么这么差呀
http://community.csdn.net/Expert/topic/4123/4123998.xml?temp=.4086878
[email protected]