The mouse hangs over the item and a tooltip appears. The tip overflows the page, causing a scrollbar that changes the layout so that the base element that launches the tip is no longer under the mouse pointer, so the tip leaves.
The tip leaves, so the scroll bar leaves, and now the mouse is again above the element.
Rinse, rinse, repeat.
If I could make sure that the tip is not too big to cause scrolling, this will solve my problem.
EDIT: after reading the comments, some things to clarify: The div contains text that may differ. If I can, I want to show the whole text. The location of the div should be next to the element over which the mouse tip has ended. So, key, I need to know if I need to trim the text.
I found this link:
http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
which contains this puzzle piece, figuring out how big the browser is:
function alertSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
window.alert( 'Width = ' + myWidth );
window.alert( 'Height = ' + myHeight );
}
source
share