
March 19th, 2004, 12:42 AM
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Problem when positioning a layer
Hi,
I have this small layer which has a monthly calendar for users to pick a date. Everything works just fine, the problem is that sometimes I need to have many date fields in a screen and the layer gets its position from the mouse position so it shows next to the button that calls it. The function is:
function showLayer(){
Layer1.style.visibility="visible";
Layer1.style.top=event.clientY+10;
Layer1.style.left=event.clientX-180;
}
The problem is that when you have to scroll down because the page gets longer, the layer shows way up. I know that this happens because x and y tell it the position of the screen but I would need to add the offset that has been scrolled. Is there a way to do this? how do I know the portion of screen that has been scrolled? If it helps, this is the code I used to create the layer.
<div id="Layer1" style="position:absolute; width:198px; height:190px;
z-index:1; left: 560px; top: 415px; visibility:hidden; background-color: #FFFFFF;
layer-background-color: #FFFFFF; border: 1px solid #000000; overflow: hidden"> </div>
Thanks in advance.
|