I have a small image. When I click on the image, I want a div to popup right at the mouse position. This is my code:
[CODE] function getRoomGridList(param)
{
var mylist = document.getElementById(“<%= txt_RoomGridList.ClientId %>”);
mylist.value = param;
var holderDiv = document.getElementById(‘RoomGridListDiv’);
var tempX = 0;
var tempY = 0;
var offset = 5;
if (document.all)
{
tempX = window.event.clientX + document.body.scrollLeft;
tempY = window.event.clientY + document.body.scrollTop;
}
else
{
tempX = window.event.pageX;
tempY = window.event.pageY;
}
if (tempX < 0)
{
tempX = 0;
}
if (tempY = 0)
{
tempY = 0;
}
holderDiv.style.top = (tempY + offset) + ‘px’;
holderDiv.style.left = (tempX + offset) + ‘px’;
holderDiv.style.display = ‘block’;
}
The first two lines have to do with aspx and feeding some text into an input inside the div.
And here’s the CSS:
[CODE]#RoomGridListDiv {
display: none;
position: absolute;
z-index: 10000;
}
It doesn’t work in IE or FF. In the FF JavaScript console, I get an error telling me that window.event is undefined. So I tried to add and alert(window.event.type) and then I get an error telling me that window.event doesn’t have any properties.
I’m calling this function from an onclick of the image.
What am I missing?
Thanks,
Natalie