<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>js网页版</title>
</head>
<body>
<div>
<a href="#" id="ifr_player" style="width: 500px;height: 150px;line-height: 50px;border: 1px solid #74A5ED;margin:0 auto; display: block">
js网页版 <br>
js模拟点击坐标、鼠标轨迹 <br>
js抓取点击坐标、鼠标轨迹
</a>
</div>
<script>
var imitateClick = function(oElement, iClientX, iClientY) {
var oEvent;
if (document.createEventObject) {
oEvent = document.createEventObject();
oEvent.clientX = iClientX;
oEvent.clientY = iClientY;
oElement.fireEvent("onclick", oEvent)
} else {
oEvent = document.createEvent("MouseEvents");
oEvent.initMouseEvent("click", true, true, document.defaultView, 0, 0, 0, iClientX, iClientY);
oElement.dispatchEvent(oEvent)
}
};
function iter(oElement,clientX,clientY) {
var mousemove = document.createEvent("MouseEvent");
mousemove.initMouseEvent("mousemove", true, true, window, 0, clientX, clientY, clientX, clientY, 0, 0, 0, 0, 0, null);
oElement.dispatchEvent(mousemove);
}
window.setTimeout(function() {
obj = document.getElementById("ifr_player");
obj.target = '_self';
var _owh = obj.getBoundingClientRect();
var _ox=_owh.width,_oh=_owh.height;
_ox = Math.floor(Math.random() * _ox+1);
_oh = Math.floor(Math.random() * _oh+1);
_ox=_ox+_owh.x;
_oh=_oh+_owh.y;
console.log('t:--' + _ox + 'r:--' + _oh);
iter(obj, _ox, _oh);
imitateClick(obj, _ox, _oh);
}, 1000);
__A(document.getElementById("ifr_player"), "click", do_click);
__A(document.getElementById("ifr_player"), "mousemove", __XY);
function __G(d, c) {
c = c || window;
if ("string" === typeof d || d instanceof String) {
return c.document.getElementById(d)
} else {
if (d && d.nodeName && (d.nodeType == 1 || d.nodeType == 9)) {
return d
}
}
return d
}
function __A(c, d, e) {
c = __G(c);
d = d.replace(/^on/i, "").toLowerCase();
if (c.addEventListener) {
c.addEventListener(d, e, false)
} else {
if (c.attachEvent) {
c.attachEvent("on" + d, e)
}
}
return c
}
var x = 0, y = 0;
xn = 0;
/**
* 点击坐标
* @param i
* @private
*/
function __XY(i) {
if (xn > 10) {
return
}
if (x == 0) {
x = i.clientX;
} else {
x = x + "," + i.clientX;
}
if (y == 0) {
y = i.clientY;
} else {
y = y + "," + i.clientY;
}
xn++;
}
function do_click(i){
var V = "&b=" + i.clientX + ' ;' + i.clientY + '&g=' + x + ';' + y;
console.log(V);
}
function __Z(i) {
i = i || window.event;
this.target = i.target || i.srcElement
}
</script>
</body>
</html>版权声明:本文为lctmei原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。