百度一堆什么oninput、onchang等等方法,都不是我要的,input:hidden,js更改value值得话,只有onpropertychange能监听到,所以研究出这个定时器检查方法
主要方法如下
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
| var onpropertychanges_byxl = { data : Array(), forData : Array(), FunData : Array(), getData : function(key){ return this.data[key]; }, getFunData : function(key){ return this.FunData[key]; }, getIds : function(){ return this.forData; }, setData : function(key, value) { this.data[key] = value; this.forData.push(key); return; }, setFunData : function(key, value) { this.FunData[key] = value; return; }, updateData : function(key,value){ this.data[key]=null; this.data[key]=value; } };
function addUpdateListener(id,method){ onpropertychanges_byxl.setData(id,document.getElementById(id).value); onpropertychanges_byxl.setFunData(id,method); }
function isUpdate_byxl(){ var ar=onpropertychanges_byxl.getIds(); for (var i = 0; i < ar.length; i++) { var a=document.getElementById(ar[i]).value; a=onpropertychanges_byxl.getData(ar[i]); if(document.getElementById(ar[i]).value!=onpropertychanges_byxl.getData(ar[i])){ onpropertychanges_byxl.getFunData(ar[i])(); onpropertychanges_byxl.updateData(ar[i],document.getElementById(ar[i]).value) } } }
window.setInterval(isUpdate_byxl,300);
|
上面一段可进行压缩加密
1
| eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('j 3={4:[],d:[],9:[],7:2(a){c 1.4[a]},i:2(a){c 1.9[a]},e:2(){c 1.d},h:2(a,b){1.4[a]=b;1.d.s(a)},f:2(a,b){1.9[a]=b},g:2(a,b){1.4[a]=l;1.4[a]=b}};2 m(a,b){3.h(a,5.6(a).8);3.f(a,b)}2 k(){o(j a=3.e(),b=0;b<a.p;b++)5.6(a[b]),3.7(a[b]),5.6(a[b]).8!=3.7(a[b])&&(3.i(a[b])(),3.g(a[b],5.6(a[b]).8))}q.r(k,n);',29,29,'|this|function|onpropertychanges_byxl|data|document|getElementById|getData|value|FunData|||return|forData|getIds|setFunData|updateData|setData|getFunData|var|isUpdate_byxl|null|addUpdateListener|300|for|length|window|setInterval|push'.split('|'),0,{}))
|
调用方式
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
|
function testFun(){ console.log("1"); } function tests(){ console.log("2"); } function testss(){ console.log("3"); }
addUpdateListener("test",testFun);
addUpdateListener("test1",tests);
addUpdateListener("test2",testss);
addUpdateListener("test2",function(){
});
|