File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Ajax tooltip position problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax tooltip position problem" Watch "Ajax tooltip position problem" New topic
Author

Ajax tooltip position problem

Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
Hi guys,

I have been using an ajax tooltip, which has been working fine until I started using struts tiles.

In my mainLayout.jsp (Defines layout for all tiled pages)I also have a scrollable pane (scrollabletable.js).

The problem is that when the page loads the first 2 tooltips show fine until I scroll down then I cant see the other tooltips because its like the page has not refreshed the position of the tooltips to match the scrolling.

Can anyone help me out with this?

Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Sounds like your code does not account for scrollTop and scrollLeft.

Eric
Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
could you elaborate some more on that?

thanks for the reply
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Without seeing the tooltip code. No...

Eric
Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
think this is main part of interest.

Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
can anyone offer any suggestions?
Jason Edgewalker
Greenhorn

Joined: Aug 12, 2008
Posts: 1
Despite the fact that, on the face of it, this shouldn't be a big deal, the problem of calculating offset can be messy. Not surprisingly, the solution varies between browsers.

There's a great section in one of O'Reilly's DHTML books that talks about this. Here's a snippet that might be helpful, because it deals with scroll offset, which has to be taken into account for IE.

Hopefully it's helpful.

function getPageEventCoords(evt) {
var coords = {left:0, top:0};
if (evt.pageX) {
coords.left = evt.pageX;
coords.top = evt.pageY;
} else if (evt.clientX) {
coords.left =
evt.clientX + document.body.scrollLeft - document.body.clientLeft;
coords.top =
evt.clientY + document.body.scrollTop - document.body.clientTop;
// include html element space, if applicable
if (document.body.parentElement && document.body.parentElement.clientLeft) {
var bodParent = document.body.parentElement;
coords.left += bodParent.scrollLeft - bodParent.clientLeft;
coords.top += bodParent.scrollTop - bodParent.clientTop;
}
}
return coords;
}
Danny Carson
Greenhorn

Joined: Aug 05, 2008
Posts: 18
Hey

Thanks for the reply. I ended up scrapping the scroll table in the end.
But I will keep the book in mind for the future.

Cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax tooltip position problem