如何在鼠标停止时显示Ballon工具提示 [英] How to Show Ballon tooltip when mouse stops

查看:154
本文介绍了如何在鼠标停止时显示Ballon工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[edit]
所以我使用了下面建议的一个javascript工具提示。如果你搬家的话,我得到了你停下来隐藏的提示。唯一的问题是它在我这样做时有效:

[edit] So I used one of the javascript tooltips suggested below. I got the tips to show when you stop and hide if you move. The only problem is it works when I do this:

document.onmousemove = (function() {
    var onmousestop = function() {
        Tip('Click to search here');
        document.getElementById('MyDiv').onmousemove = function() {
        UnTip();
    };
    }, thread;

    return function() {
        clearTimeout(thread);
        thread = setTimeout(onmousestop, 1500);
    };
})();

但我希望该功能仅适用于特定div,如果我将第一行更改为 document.getElementById('MyDiv')。onmousemove =(function(){我得到一个javascript错误document.getElementById('MyDiv')为null我错过了什么.... ??

But I want the function to only apply to a specific div and if I change the first line to "document.getElementById('MyDiv').onmousemove = (function() {" I get a javascript error document.getElementById('MyDiv') is null What am I missing....??

[/ edit]

当用户鼠标停留在元素上超过1.5秒时,我想显示气球样式消息。然后,如果他们移动鼠标我想隐藏气球。我正在尝试使用我发现的野外发现的一些JavaScript代码。这是我用来检测鼠标何时停止的代码:

I want to display a balloon style message when the users mouse stops on an element from more than say 1.5 seconds. And then if they move the mouse I would like to hide the balloon. I am trying to use some JavaScript code I found posted out in the wild. Here is the code I am using to detect when the mouse has stopped:

document.onmousemove = (function() {
    var onmousestop = function() {
        //code to show the ballon
        };
    }, thread;

    return function() {
        clearTimeout(thread);
        thread = setTimeout(onmousestop, 1500);
    };
})();

所以我有两个问题。一,有没有人有一个推荐的轻量级javascript气球,将显示在光标位置。二,检测鼠标停止代码工作正常,但我很难知道如何检测鼠标已经开始再次移动并隐藏气球。谢谢...

So I have two questions. One, does anyone have a recommended lightweight javascript balloon that will display at the cursor location. And two, the detect mouse stopped code works ok but I am stumped on how to detect that the mouse has started moving again and hide the balloon. Thanks...

推荐答案

要回答这个问题有点晚了,但这对有需要的人有用。

A bit late to be answering this, but this will be helpful for those in need.

我需要此功能才能检测鼠标何时停止移动一段时间,以便在悬停在视频上时隐藏HTML / JS播放器控制器。这是工具提示的修订代码:

I needed this function to be able to detect when the mouse stopped moving for a certain time to hide an HTML/JS player controller when hovering over a video. This is the revised code for the tooltip:

document.getElementById('MyDiv').onmousemove = (function() {
    var onmousestop = function() {
        Tip('Click to search here');
    }, thread;

    return function() {
        UnTip();
        clearTimeout(thread);
        thread = setTimeout(onmousestop, 1500);
    };
})();

在我的例子中,我使用了一些jQuery来为我的播放器控制器选择元素:

In my case, I used a bit of jQuery for selecting the elements for my player controller:

$('div.video')[0].onmousemove = (function() {
    var onmousestop = function() {
        $('div.controls').fadeOut('fast');
    }, thread;

    return function() {
        $('div.controls').fadeIn('fast');
        clearTimeout(thread);
        thread = setTimeout(onmousestop, 1500);
    };
})();

这篇关于如何在鼠标停止时显示Ballon工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆