当窗口获得焦点的时候,自动为页面上所有的input为button,以及所有的button添加mouseup事件。
当用户在进行操作的时候就会全部记录下来。
代码:
window.onfocus=function setEventFunc(){
var inputs = document.getElementsByTagName("input");
for(i=0;i<inputs.length;i++){
if(inputs[i].type=="button"){
inputs[i].onmouseup=recordOp;
}
}
var btns = document.getElementsByTagName("button");
for(i=0;i<btns.length;i++){
btns[i].onmouseup=recordOp;
}
}
recordOp是保存信息函数。在用户触发mouseup事件的时候记录下需要的信息。
本文介绍了一种在页面获得焦点时,自动为所有input和button元素添加mouseup事件的实现方式,通过记录这些事件,可以实时跟踪用户的操作行为。
1581

被折叠的 条评论
为什么被折叠?



