当窗口获得焦点的时候,自动为页面上所有的input为button,以及所有的button添加mouseup事件。
当用户在进行操作的时候就会全部记录下来。
代码:
window.οnfοcus=function setEventFunc(){
var inputs = document.getElementsByTagName("input");
for(i=0;i<inputs.length;i++){
if(inputs[i].type=="button"){
inputs[i].οnmοuseup=recordOp;
}
}
var btns = document.getElementsByTagName("button");
for(i=0;i<btns.length;i++){
btns[i].οnmοuseup=recordOp;
}
}
recordOp是保存信息函数。在用户触发mouseup事件的时候记录下需要的信息。