homepage Welcome to WebmasterWorld Guest from 54.235.16.159
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
showPopup() shows up too eager
mongoloid001




msg:1473727
 9:17 pm on Jun 16, 2003 (gmt 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>

 

HocusPocus




msg:1473728
 11:51 pm on Jun 16, 2003 (gmt 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);

grahamstewart




msg:1473729
 12:07 am on Jun 17, 2003 (gmt 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.

mongoloid001




msg:1473730
 9:33 pm on Jun 27, 2003 (gmt 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

le_gber




msg:1473731
 7:59 am on Jun 30, 2003 (gmt 0)

Have a look here:

[google.com...]

Overlib will be your solution, I think

Leo

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved