某国外网站的登录页面的一段JS代码
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 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 53 54 55 56 57 |
// getObj() and getObjNN4() // cross browser object identify (by id name) // returns an object with two properties: // .obj (give access to the object itself) // .style (give access to the object styles) function getObj(name) { if (document.getElementById) { this.obj = document.getElementById(name); if (document.getElementById(name).style) { this.style = document.getElementById(name).style; } } else if (document.all) { this.obj = document.all[name]; if (document.all[name].style) { this.style = document.all[name].style; } } else if (document.layers) { this.obj = getObjNN4(document,name); this.style = this.obj; } return this; } function getObjNN4(obj,name) { var x = obj.layers; var foundLayer; for (var i=0;i<x.length;i++) { if (x[i].id == name) foundLayer = x[i]; else if (x[i].layers.length) var tmp = getObjNN4(x[i],name); if (tmp) foundLayer = tmp; } return foundLayer; } function objExists(name) { var b = false; if (document.getElementById) { if (document.getElementById(name)) b = true; } else if (document.all) { if (document.all[name]) b = true; } else if (document.layers) { if (getObjNN4(document,name)) b = true; } return b; } |