1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
function getWindowWidth () {
if (ie) return document.body.offsetWidth;
else return window.innerWitdh;
}
var monPadding = 10; // px
var windowWidth = getWindowWidth()
var objWidth = maDiv.style.width // ou maDiv.offsetWidth peut-etre plutôt
var totalOffsetLeft = maDiv.offsetLeft;
var parent = maDiv;
while ( parent = parent.parentNode ) {
totalOffsetLeft += parent.offsetLeft;
}
if ( (totalOffsetLeft + objWidth ) > windowWidth ) {
maToolTip.style.left -= (( ( totalOffsetLeft + objWidth ) - windowWidth ) + monPadding )
// Enfin, il va de soit que ce petit coup de décalage tu le fait selon la manière dont tu positionne ton infobulle hein, a toi de voir.
} |
Partager