当前位置:网站首页>避免按钮重复点击的小工具bimianchongfu.queren()
避免按钮重复点击的小工具bimianchongfu.queren()
2022-07-01 08:26:00 【海宏AA】
按钮后台可能执行很长时间,这期间如果客户等不及再次点了按钮,可能会重复触发。
比如资产折旧,运行很长时间。

所以可以做一个hf_running的hiddenfield对象,设置值1表示正在运行,0表示没有。为兼容性用的纯js。
封装好了:
//避免重复运行,需要加一个hf_running的控件。用法:
//if (!bimianchongfu.queren('确认继续吗?')) return;
//执行具体业务代码
//执行完后,清空hf_running的值或者改成0
var bimianchongfu = {
kongjian: { objRunning: "hf_running" },
//检查是否正在运行,并提示,并设置值
queren: function (AConfirmMsg, lShowAlert, strShowAlert, lMarkIsRunning) {
var rt = this.zhengzaiyunxing(lShowAlert, strShowAlert, false);//检查正在运行
if (rt) return false; //正在运行,返回
//确认
var s = AConfirmMsg;
if (AConfirmMsg == undefined || AConfirmMsg == null) s = "";
if (s != "") if (!(rt = confirm(s))) return false;
//
if (lMarkIsRunning == undefined || lMarkIsRunning == null || lMarkIsRunning == true)
this.set("1");
//
return true;
},
//读取是否正在运行
zhengzaiyunxing: function (lShowAlert, strShowAlert, lMarkIsRunning) {
var obj = this.kongjian.objRunning, v = "", l = false, s = strShowAlert, lAlert = lShowAlert;
if (obj == undefined || obj == null) obj = document.getElementById("hf_running");
else if (typeof (obj) == "string") obj = document.getElementById(obj);
if (obj == undefined || obj == null) obj = document.getElementById("hf_running");
if (obj != null && this.kongjian.objRunning == null) this.kongjian.objRunning = obj;//记下来
v = obj.value; //取值
l = !(v == undefined || v == null || v == "" || v == "0" || v == "false");
//提示信息
if (l) { //正在运行
if (lShowAlert == undefined || lShowAlert == null) lAlert = true;
if (strShowAlert == undefined || strShowAlert == null) s = "正在运行,请稍候";
if (lAlert && s != "") alert(s);
} else { //没有运行,标记为正在运行
if (lMarkIsRunning == undefined || lMarkIsRunning == null || lMarkIsRunning == true)
this.set("1");
}
//完成返回
return l;
},
//设置值
set: function (val) {
var obj = this.kongjian.objRunning, tp = typeof (obj);
if (tp == "object") obj.value = val;
else if (tp == "string") document.getElementById(obj).value = val;
else document.getElementById("hf_running").value = val;
}
};边栏推荐
- AES简单介绍
- 手工挖XSS漏洞
- 使用beef劫持用戶瀏覽器
- How to recruit Taobao anchor suitable for your own store
- Li Kou 1358 -- number of substrings containing all three characters (double pointer)
- shardingSphere
- shardingSphere
- Learn reptiles for a month and earn 6000 a month? Tell you the truth about the reptile, netizen: I wish I had known it earlier
- Transaction method call @transactional
- 【无标题】
猜你喜欢
![[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)](/img/3e/75a1152f9cdf63c6779fdadec702a0.jpg)
[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)

Connect timed out of database connection

Redis publish subscription

seaborn clustermap矩阵添加颜色块

P4 安装bmv2 详细教程

CPU design practice - Chapter 4 practical tasks - simple CPU reference design and debugging
![Matlab [functions and images]](/img/8a/d2f68b5a7ed396ad20234c0aa24953.jpg)
Matlab [functions and images]

The era of low threshold programmers is gone forever behind the sharp increase in the number of school recruitment for Internet companies

使用beef劫持用户浏览器

factory type_id::create过程解析
随机推荐
Intelligent water and fertilizer integrated control system
[redis] it takes you through redis installation and connection at one go
[detailed explanation of Huawei machine test] judgment string subsequence [2022 Q1 Q2 | 200 points]
2022 Chinese cook (technician) simulation test and Chinese cook (technician) practice test video
XX攻击——反射型 XSS 攻击劫持用户浏览器
Matlab [function derivation]
Agrometeorological environment monitoring system
2022.2.15
Anddroid text to speech TTS implementation
Conception et mise en service du processeur - chapitre 4 tâches pratiques
Mavros sends a custom topic message to Px4
Book of quantitative trading - reading notes of the man who conquers the market
Review of week 280 of leetcode
Thread safety analysis of [concurrent programming JUC] variables
Codeworks round 803 (Div. 2) VP supplement
使用 setoolkit 伪造站点窃取用户信息
Leetcode T40: 组合总和II
《微机原理》-绪论
Manually dig XSS vulnerabilities
shardingSphere