firehorse24
Programmer
Hi,
I'm tring to do onmouseover to each row in a <table>. I'd like the popup box shown next to each row when I move the mouse over. But the popup box always shown on the same position in the page.
If I don't use <table>, then the popup box follow the rows.
please see my code with <table>
Following is the HTML code without <table>
Thank you a lot ahead!
I'm tring to do onmouseover to each row in a <table>. I'd like the popup box shown next to each row when I move the mouse over. But the popup box always shown on the same position in the page.
If I don't use <table>, then the popup box follow the rows.
please see my code with <table>
Code:
<html>
<head>
<title>Popup Box</title>
<style>
#messageBox{
border-right: 1px solid #000000;
position: absolute;
width: 300px;
height: 100px;
z-index: 1;
background-color: #FFFFFF;
border-style: solid;
border-width: 1px;
display:none;
}
}
#contents{
width: 300px;
height: 100px;
z-index: 2;
}
</style>
<script language="javascript">
function show(obj){
messageBox.style.top=obj.offsetTop
messageBox.style.left=obj.offsetLeft+obj.offsetWidth+ 5 +"px"
contents.innerHTML = "test"
messageBox.style.display="block"
}
</script>
</head>
<body>
<table border="1">
<tr><td>
<a href="#" onmouseover="show(this)" onmouseout="messageBox.style.display='none'">go to google </a>
</td></tr>
<tr><td>A</td></tr>
<tr><td>
<a href="#" onmouseover="show(this)" onmouseout="messageBox.style.display='none'">go to msn </a>
</td></tr>
<tr><td>A</td> </tr>
<tr><td>B</td> </tr>
<tr><td>S</td> </tr>
<tr><td>D</td> </tr>
<tr><td>
<a href="#" onmouseover="show(this)" onmouseout="messageBox.style.display='none'">go to DIC</a>
</td></tr>
<tr><td>S</td> </tr>
<tr><td>D</td> </tr>
</table>
<div id="messageBox" onmouseout="this.style.display='none'" >
<div id="contents"></div>
</div>
</body>
</html>
Following is the HTML code without <table>
Code:
<body>
<p>
<a onmouseover="show(this)" onmouseout="messageBox.style.display='none'" href="#">go to google</a>
</p>
<p>
<a onmouseover="show(this)" onmouseout="messageBox.style.display='none'" href="#">go to msn</a>
</p>
<br>
<br>
<p>
<a onmouseover="show(this)" onmouseout="messageBox.style.display='none'" href="#">go to DIC</a>
</p>
<div id="messageBox">
<div id="contents"></div>
</div>
</body>
Thank you a lot ahead!