Welcome to WebmasterWorld Guest from 54.221.9.209

Forum Moderators: open

Message Too Old, No Replies

showPopup() shows up too eager

     
9:17 pm on Jun 16, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 24, 2003
posts:56
votes: 0


I have the following javascript that shows a tooltip for anything that mouseover() an element. The problem is that if the mouse entered the element from the right-top corner, the popup will show up instantly. However at the time the mouse stopped moving, it's right on top of the tooltip, which is like a mouseout() event for all javascript is corcerned, so the tooltip would be closed, then popup right again.

What I need is something that tells the mouse has been paused for 0.3sec.

Does javascript or IE support this functionality?

Thanks!

<code>

var popup = window.createPopup();
var popupTimer;
function showPopup(string)
{
var popupBody = popup.document.body;
popupBody.style.border = "1px solid black";
popupBody.style.margin = "1px 0px 4px 4px";
popupBody.style.backgroundColor = '#F5F5DC';
popupBody.innerHTML = string;
realWidth = popupBody.scrollWidth;
realHeight = popupBody.scrollHeight;
popupTimer = window.setTimeout("popup.show(" + (event.x + 10) + ", " + (event.y+10) + ", " + (realWidth + 6) + ", " + realHeight + ", window.document.body)", 750);
}

function hidePopup()
{
popup.hide();
window.clearTimeout(popupTimer);
}

</code>

11:51 pm on June 16, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 27, 2002
posts:125
votes: 0


This should get you started, not elegant, very messy. Not recommended.

var oldMouseX=0;
var oldMouseY=0;
var mousePaused = 0;

function getMousePos (e) {
if(arguments[0])
{
mouseX = e.clientX;
mouseY = e.clientY;
}
if(mouseX==oldMouseX && mouseY ==oldMouseY)
{
mousePaused = 1;
}
else
{
mousePaused = 0;
}
oldMouseX=mouseX;
oldMouseY=mouseY;
}

document.onmousemove =getMousePos;
setInterval(getMousePos(),300);

12:07 am on June 17, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 8, 2003
posts:1429
votes: 0


As an aside: do you know that you can do this in HTML by specifying the title attribute of an element? Most browser (including IE) render this as a tooltip.
9:33 pm on June 27, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 24, 2003
posts:56
votes: 0


<quote>
As an aside: do you know that you can do this in HTML by specifying the title attribute of an element? Most browser (including IE) render this as a tooltip.
</quote>

Thanks!
I realized title works too; however, my tooltip can be pretty long, the limit is 4,000 words. So I needed a customized pop-up window

7:59 am on June 30, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 14, 2003
posts:1550
votes: 0


Have a look here:

[google.com...]

Overlib will be your solution, I think

Leo