简体   繁体   English

JavaScript停止第二个setTimeOut函数

[英]Javascript stop second setTimeOut function

I have a JS library where on submit form setTimeOut function executes. 我有一个JS库 ,可在提交表单时执行setTimeOut函数。

I want to execute another setTimeOut function before or after form submission and don't want to execute the setTimeOut function that is in the JS library on submit event. 我想在提交表单之前或之后执行另一个setTimeOut函数,并且不想在setTimeOut事件上执行JS库中的setTimeOut函数。

I can not/don't want to declare like myVar = setTimeout in library so that later I can use clearTimeout(myVar); 我不能/不想在库中声明myVar = setTimeout ,以便以后可以使用clearTimeout(myVar); to clear the timeout function in the library from my end. 从头开始清除库中的超时功能。

Any idea? 任何想法?

For example: 例如:

library.js library.js

Form submit event handler with timeout function 具有超时功能的表单提交事件处理程序

contact.html contact.html

$('#contact').submit();
setTimeout(function() {
    //some tasks here and dont execute library.js timeout function
}, 5);

I didn't find any good solution but I have now a temporary solution just increase the timer+1. 我没有找到任何好的解决方案,但现在有了一个临时解决方案,只是增加了timer + 1。 Means if we have 1000ms in library as mentioned in the question, I run another timeout function with 10001ms 意味着如果我们在问题中提到的库中有1000ms,我将使用10001ms运行另一个超时功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM