java 禁止 事件_Java脚本:mousestop事件(Java Script: mousestop event)

Java脚本:mousestop事件(Java Script: mousestop event)

对于某些功能,我正在处理mousemove事件。 mousemove事件侦听器在一个不需要的单个线性鼠标手势中被多次调用。 我需要实现一个自定义事件,当鼠标停止运动时将调用该事件。 我猜它可以在mousemove上实现一些延迟功能。

请帮助我这方面。 谢谢

For some feature, I am working on mousemove event. mousemove event listener is invoked a number of times with in a single linear mouse gesture that is not required. I need to implement a custom event that will be invoked when mouse will stop its motion. I have a guess that it can be implemented on top of mousemove with some delay feature.

Please help me in this regard. Thanks

原文:https://stackoverflow.com/questions/3262501

更新时间:2020-03-02 15:10

最满意答案

你大部分时间都在那里:

function waitForMouseStop(callback) {

var timer;

function stoppedMoving(evt) {

document.onmousemove = null;

callback();

}

function moveHandler(evt) {

evt = evt || window.event;

if (timer) {

window.clearTimeout(timer);

}

timer = window.setTimeout(function() {

stoppedMoving(evt);

}, 500);

}

document.onmousemove = moveHandler;

}

waitForMouseStop(function() {

alert("Stopped");

});

You're most of the way there:

function waitForMouseStop(callback) {

var timer;

function stoppedMoving(evt) {

document.onmousemove = null;

callback();

}

function moveHandler(evt) {

evt = evt || window.event;

if (timer) {

window.clearTimeout(timer);

}

timer = window.setTimeout(function() {

stoppedMoving(evt);

}, 500);

}

document.onmousemove = moveHandler;

}

waitForMouseStop(function() {

alert("Stopped");

});

2010-07-19

相关问答

只需在drop事件中调用控制器上的操作即可。 您可以像这样使用jQuery : $.ajax({

type: "POST",

url: yourUrl,

data: dataSerializedAsJson,

success: function() { /* action */ },

dataType: "json"

});

Just call an action on your controller in the drop event. You can use jQuery

...

将函数名称作为字符串传递确实是一个坏主意。 以字符串格式附加代码也是如此,例如"(this.getAttribute('"+param_trs+"'))" 。 这将需要解析,就像eval一样。 效率低,可能导致与eval相关的问题 。 函数可以作为参数传递,而不是作为字符串传递,而是作为实际函数引用。 其次,事件处理程序函数在执行时检索属性值更合适,而不是之前。 所以这是一个提出这个想法的片段。 该演示将采用data-inc属性来确定应该增加多少数量。 function addEventListe

...

啊,这很简单。 感谢所有答案。 方案 : 对服务器端事件使用OnClick属性,对客户端事件使用OnClientclick进行验证。 OnClientClick javascript方法将返回true和false ,它决定了serveride onclick事件是否会触发。 代码将是这样的

function DoPost() {

var chk = document.getElementById('

...

除了missing () ,你的代码工作正常,试试吧: var main = function(){

$(".submitbtn").click(function() {

alert("yay");

});

};

$(document).ready(main); .submitbtn {background: orange; cursor: pointer; float: left; padding: .2em 1em; }

这将“自动点击”按钮,从而触发处理其点击的任何服务器端代码。 If Button1 already exists, have such code:

...

请查看此博客,以便写入事件日志。 您将能够从自定义源创建自定义事件。 但我认为您不能从系统拥有的源创建虚假事件,因此您可能需要配置Splunk以获取自定义源。 New-EventLog –LogName system –Source "App1"

Write-EventLog -LogName "System" -Source "App1" -EventID 1234 -EntryType Error -Message "Some Error message"

Take a look at

...

jQuery("#textbox").blur(function() {

ajaxFunction(jQuery("#textbox").val());

});

function ajaxFunction(code){

// Your ajax call

}

试试这个希望完全有这个帮助。 I finally got the solution.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值