- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章JavaScript实现滑块验证解锁由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
本文实例为大家分享了JavaScript实现滑块验证解锁的具体代码,供大家参考,具体内容如下 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1.0"
>
// 引入矢量图标库
<
link
rel
=
"stylesheet"
href
=
"https://at.alicdn.com/t/font_2248239_eso2z5bskxk.css"
>
<
title
>Document</
title
>
<
style
>
* {
margin: 0;
padding: 0;
}
.box {
width: 300px;
height: 40px;
line-height: 40px;
text-align: center;
background-color: #e8e8e8;
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
position: relative;
margin-top: 100px;
margin-left: 200px;
}
.box .bgColor {
position: absolute;
left: 0;
top: 0;
width: 40px;
height: 40px;
}
.box .tips {
position: absolute;
width: 100%;
height: 40px;
line-height: 40px;
font-size: 14px;
color: #000;
text-align: center;
user-select: none;
}
.ball {
width: 50px;
height: 38px;
border: 1px solid #ccc;
background: #fff;
text-align: center;
cursor: move;
position: absolute;
top: 0;
left: 0;
}
</
style
>
</
head
>
<
body
>
<
div
class
=
"box"
>
<
div
class
=
"bgColor"
></
div
>
<
div
class
=
"tips"
>滑动验证</
div
>
<
div
class
=
"ball"
><
i
class
=
"iconfont icon-double-arro-right"
></
i
></
div
>
</
div
>
</
body
>
<
script
>
var box = document.getElementsByClassName("box")[0];
var ball = document.getElementsByClassName("ball")[0];
var bgColor = document.getElementsByClassName("bgColor")[0];
var tips = document.getElementsByClassName("tips")[0];
// 设置成功状态
var isSuccess = false; //默认为false 不成功
ball.onmousedown = function(e) {
var e = e || window.event;
// 获取鼠标相对于事件源左上角的位置
var posx = e.offsetX;
// 每次鼠标按下时 清除动画样式
ball.style.transition = "";
bgColor.style.transition = "";
document.onmousemove = function(e) {
var e = e || window.event;
var x = e.pageX - box.offsetLeft - posx;
var max = box.clientWidth - ball.clientWidth;
if (x <= 0) {
x = 0;
}
if (x >= max) {
x = max;
}
bgColor.style.width = x + "px";
ball.style.left = x + "px";
bgColor.style.backgroundColor = "#6ff";
if (x == max) {
success();
}
}
document.onmouseup = function() {
// 如果没有解锁成功则返回原点
if (!isSuccess) {
bgColor.style.width = 0 + "px";
ball.style.left = 0 + "px";
ball.style.transition = "left 0.6s linear";
bgColor.style.transition = "width 0.6s linear";
}
// 鼠标抬起时,移除鼠标移动事件和鼠标抬起事件
document.onmouseup = null;
document.onmousemove = null;
}
}
// 定义一个滑块解锁成功的方法
function success() {
isSuccess = true;
// 获取图标
var icon = ball.firstElementChild;
tips.textContent = "解锁成功";
bgColor.style.backgroundColor = "lightgreen";
icon.className = "iconfont icon-gou";
icon.style.color = "lightgreen";
//滑动成功时,移除鼠标按下事件
ball.onmousedown = null;
}
</
script
>
</
html
>
|
效果图如下
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
原文链接:https://blog.csdn.net/weixin_53278262/article/details/112172233 。
最后此篇关于JavaScript实现滑块验证解锁的文章就讲到这里了,如果你想了解更多关于JavaScript实现滑块验证解锁的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我注意到,当我打开我的应用程序并等待足够长的时间让我的手机自行锁定时,当我解锁它时,当前内容 View 未处于全屏模式。它不显示顶部栏,而是全黑线...如果我去另一个 Activity 并返回它再次修
我必须处理设计限制(依赖性问题)以不对互斥体使用范围保护。 示例代码: template class Test { MutexType myMutex; public: void f(
我正在尝试像这样使 my_class 线程安全。 class my_class { const std::vector& get_data() const { //lock so that
我想让手机在手机被锁定(锁定 = 键盘被锁定)并且用户想要解锁时询问一个问题(来自数据库)。如果答案正确,则手机解锁,否则手机会询问另一个问题。 我不知道如何检测解锁并在需要时解锁/锁定手机。 请帮帮
我有一个对 accept() 的阻塞调用。我从另一个线程关闭套接字,希望它能解除对 accept() 调用的阻塞,它确实如此,但我有一个情况,它没有:例如线程A进入accept(),线程B关闭sock
我在 C# 中有一个可以从多个线程调用多次的函数,我希望它只执行一次,所以我想到了这个: class MyClass { bool done = false; public void
锁定数据库的一个表 复制代码 代码如下: SELECT * FROM table WITH (HOLDLOCK) 注意: 锁定数据库的一个表的区别
我已经使用腻子在我的 ec2 实例上安装了 jenkins,从我的 Windows 系统 当我尝试通过网络访问 jenkins 时,我使用/var/lib/jenkins/secrets/initia
每次我打开我的电脑并尝试连接到 HR 数据库时,都会弹出一个错误提示被阻止,然后我转到 SQLPLUS 并以 SYSDBA 身份登录,并执行以下脚本: 我的问题是,我是否总是必须这样做?有什么办法让它
所以我的手机在引导加载程序中,我想解锁它 所以我输入 fastboot oem unlock 我明白了 D:\Minimal ADB and Fastboot>fastboot oem unlock
在我的应用程序中,我希望即使在应用程序终止后我的应用程序仍处于事件状态。我希望当“滑动解锁”我的应用程序启动时。 有可能吗?我怎样才能在不越狱的情况下做到这一点...... 这是为用户提供便利的功能。
即使我的 iPhone 使用电缆连接并解锁,它也会显示警告“Xcode 9.3 无法在 iPhone 上启动应用程序,因为设备已锁定”。我不知道该怎么办?有人对此有适当的解决方案吗?请 最佳答案 只需
我看到一个非常奇怪的行为,我试图了解它是否是这样设计的,或者只是没有从我的应用程序中正确处理。 我的应用程序以 UIAlertViews 的形式发送推送通知。当设备未锁定时,UIAlertViews
该文档说,从一个线程进行锁定并从另一个rwlock进行解锁会导致未定义的行为。我有一个数组和两个线程,一个分配它,一个释放它,这是一个周期发生的,也有一些线程在其中进行读/写操作,但是它们从不重叠,因
解锁 Oracle 表有哪些不同的技术? 我尝试过的。 获取锁定表的对象ID: SELECT object_id FROM dba_objects WHERE object_name='YOUR TA
我运行@apxchpwd.sql并用这个脚本给帐户倒霉 alter session set current_schema = APEX_050100; declare l_workspace_id
我想在 Chrome 扩展程序中提供一些高级功能。这个想法是,只要用户通过 PayPal 捐赠了一定金额,就可以使用后者的附加功能。 目前我的策略是这样的: 1/。用户填写 PayPal 表格。 2/
我构建了一个包含 IAP(应用内购买)的应用。该应用程序是使用 UINavigationController 构建的。当用户决定购买内容时,解锁功能会解锁该内容。然后,用户点击后退按钮,他们将返回主菜
我有一个只能通过静态方法从外部访问的类。然后,这些静态方法创建该类的一个对象以在该方法中使用,然后它们返回并且该对象可能被销毁。该类是几个配置文件的 getter/setter,现在我需要在对配置文件
我可以在超出 scoped_lock 范围之前解锁互斥锁吗?我怎么能那样做? {boost::mutex::scoped_lock lock(mutex); if(conditionaA) {
我是一名优秀的程序员,十分优秀!