window.onload = function () {
getCapthaId();
function getCapthaId() {
// initNECaptcha 为全局函数,可直接调用
initNECaptcha({
captchaId: 'c72c6f12ee364001a4b0374cd5358a19', // 这里填入申请到的验证码id
element: '#captcha_div',
mode: 'embed',
width: '320px',
onVerify: function(err, ret) {
if (!err) {
if (ret['validate']) { // true:验证通过 false:验证失败
console.log(ret)
// $.ajax({
// url: '/checkres.ac?key=' + ret,
// type: 'get',
// dataType: "text",
// success: function(res) {
// location.reload();
// }
// })
}
} else {
text = ($('.yidun_tips__text').text())
img = $('.yidun_bg-img').attr('src')
}
}
}, function(instance) {
// 初始化成功后得到验证实例instance ,可以调用实例的方法
$(".yidun_bgimg").append('<span class="point_span"></span>')
}, function(err) {
console.log(err)
// 初始化失败后触发该函数,err 对象描述当前错误信息
})
}
setTimeout(()=>{
let arr = [
[20, 30],
[80, 80],
[120, 130]
]
for(let i=0;i<arr.length;i++){
imitateClick(arr[i][0],arr[i][1]);
}
},3000)
function imitateClick( iClientX, iClientY) {
let oElement =document.querySelectorAll('.point_span')[0];
$(oElement).animate({
left:iClientX,
top:iClientY
},300,function(){
console.log(document.defaultView)
var oEvent;
if (document.createEventObject) { //For IE
oEvent = document.createEventObject();
oEvent.clientX = iClientX;
oEvent.clientY = iClientY;
oElement.fireEvent("onclick", oEvent);
} else {
oEvent = document.createEvent("MouseEvents");
// oEvent.initMouseEvent("click", true, true, window, 0, 0, 0,
// iClientX, iClientY /*, false, false, false, false, 0, null*/ );
oEvent.initMouseEvent("click", true, true, window, 0, 0, 0, (iClientX), (iClientY), false, false, false, false, 0, null);
oElement.dispatchEvent(oEvent);
$(oElement).animate({
left: 0,
top: 0
}, 60)
}
})
}
}
<form style="width: 320px;" action="/login" method="post">
<div id="captcha_div"></div>
</form>
<div class="layout_parent">
<div class="layout_label point"></div>
<div class="layout_label label_1"></div>
<div class="layout_label label_2"></div>
<div class="layout_label label_3"></div>
</div>
<script src="https://cstaticdun.126.net/load.min.js"></script>
*{margin:0;padding:0}
.layout_parent {
background: #f2f2f2;
border: 1px solid #ccc;
width: 300px;
height: 200px;
position: relative;
}
.layout_label {
position: absolute;
background: #f00;
width: 20px;
height: 20px;
}
.label_1 {
top: 30px;
left: 20px;
}
.label_2 {
top: 80px;
left: 80px;
}
.label_3 {
top: 130px;
left: 120px;
}
.point{
top: 0;
left: 0;
background: blue;
z-index: 2;
}
.point_span {
background: rgb(115, 232, 240);
height: 20px;
width: 20px;
display: block;
position: absolute;
border-radius: 50%;
top: 0;
left: 0;
}
.yidun_panel-placeholder{
position:relative;
}