function element(tagname){ return node(document.createElement(tagname)); } function node(node){ //如果参数是字符,就获取其节点对象asda if(typeof(node)=="string"){var node=document.getElementById(node);} //如果已经加过方法就直接返回; if(node.style.mark==true){return node;} //如果没有加过方法做上标记; node.style.mark=true; if(!node.style.opacity){ node.style.opacity=1; } node.remove=function(){ if(!node.parentNode){return;} node.parentNode.removeChild(node); } node.addback=function(domNode){ if(!domNode){return;} var domNode2=domNode.nextSibling; if(!domNode2){ domNode.parentNode.appendChild(node); } else{ domNode2.parentNode.insertBefore(node,domNode2); } } node.addfront=function(domNode){ if(!domNode){return;} domNode.parentNode.insertBefore(node,domNode); } node.addlast=function(parentNode){ if(!parentNode){parentNode=document.body} parentNode.appendChild(node); } node.addfirst=function(parentNode){ if(!parentNode){parentNode=document.body} parentNode.insertBefore(node,parentNode.firstChild); } node.addcss=function(styles){ for(styleitem in styles){ node.style[styleitem]=styles[styleitem]; } } node.addatts=function(atts){ for(attitem in atts){ node[attitem]=atts[attitem]; } } node.getstyle=function(){ return node.currentStyle||document.defaultView.getComputedStyle(node,null); } node.hide=function(time,end,fun){ node.style.display2=node.getstyle().display; if(isNaN(time)){time=700;} if(isNaN(end)){end=0;} if(navigator.userAgent.indexOf("MSIE")>=0){ //node.style.filter="progid\:DXImageTransform.Microsoft.Alpha\(style=0,opacity=100,finishOpacity=100\)"; var speed=1000/time; var opacity=node.style.opacity*100; var number=setInterval(function(){ opacity-=speed; node.style.filter="progid\:DXImageTransform.Microsoft.Alpha\(style=0,opacity="+opacity+",finishOpacity=100\)"; node.style.opacity=opacity/100; if(opacity<=end){ clearInterval(number); //node.style.display="none"; if(typeof(fun)=="function"){fun();} } },1) } else{ //node.style.opacity=1; var speed=10/time; var opacity=node.style.opacity; var number=setInterval(function(){ opacity-=speed; opacity=parseInt(opacity*10000)/10000; node.style.opacity=opacity; if(opacity<=(end/100)){ clearInterval(number); //node.style.display="none"; if(typeof(fun)=="function"){fun();} return; } },1) } } node.show=function(time,end,fun){ //if(node.style.display2){node.style.display=node.style.display2;} if(isNaN(time)||time==""||time==null){time=700;} if(isNaN(end)||end==""||end==null){end=100;} if(navigator.userAgent.indexOf("MSIE")>=0){ //node.style.filter="progid\:DXImageTransform.Microsoft.Alpha\(style=0,opacity=0,finishOpacity=100\)"; var speed=1000/time; var opacity=node.getop(); var number=setInterval(function(){ opacity+=speed; node.style.filter="progid\:DXImageTransform.Microsoft.Alpha\(style=0,opacity="+opacity+",finishOpacity=100\)"; node.style.opacity=opacity/100; if(opacity>=end){ clearInterval(number); if(typeof(fun)=="function"){fun();} return; } },1) } else{ //node.style.opacity=0; var speed=10/time; var opacity=node.getop()/100; var number=setInterval(function(){ opacity+=speed; opacity=parseInt(opacity*10000)/10000; node.style.opacity=opacity; if(opacity>=(end/100)){ clearInterval(number); if(typeof(fun)=="function"){fun();} return; } },1) } } node.setop=function(number){ if(isNaN(number)||number==""||number==null){number=50} if(number>100){number=100} if(number<0){number=0} if(navigator.userAgent.indexOf("MSIE")>=0){ node.style.filter="progid\:DXImageTransform.Microsoft.Alpha\(style=0,opacity="+number+",finishOpacity=100\)"; } node.style.opacity=number/100; } node.getop=function(){ return node.style.opacity*100; } node.addEvent=function(s,f){ if(node.addEventListener){ node.addEventListener(s,f,false) } else{ node.attachEvent("on"+s,f) } } node.removeEvent=function(s,f){ if(node.removeEventListener){ node.removeEventListener(s,f,false); } else{ node.detachEvent("on"+s,f) } } node.addClass=function(classname){ if(node.className==""){node.className=classname;return true;} var classnames=node.className.split(" "); for(var i=0;i=0){return true;} else{return false;} } function isie8(){ if(navigator.userAgent.indexOf("MSIE 8")>=0){return true;} else{return false;} } function isie7(){ if(navigator.userAgent.indexOf("MSIE 7")>=0){return true;} else{return false;} } function isie6(){ if(navigator.userAgent.indexOf("MSIE 6")>=0){return true;} else{return false;} } function isie5(){ if(navigator.userAgent.indexOf("MSIE 5")>=0){return true;} else{return false;} } function isff(){ if(navigator.userAgent.indexOf("Firefox")>=0){return true;} else{return false;} } function issf(){ if(navigator.userAgent.indexOf("Safari")>=0){return true;} else{return false;} } function isop(){ if(navigator.userAgent.indexOf("Opera")>=0){return true;} else{return false;} } function win(id,width,height){ //if(width==""||width==null||isNaN(width)){width=500}; //if(height==""||height==null||isNaN(height)){height=500}; var styles={ width:"100%", height:(document.documentElement.scrollHeight)+"px", backgroundColor:"#000000", top:"0", left:"0", position:"absolute", zIndex:"9999" } var bg=new element("div"); bg.addcss(styles); bg.setop(70); //bg.show(100,50); bg.addlast(); if(isie6()){ var selects=document.getElementsByTagName("select"); for(var i=0;i0) { nr[nr.length] = me[t = Math.floor(Math.random() * me.length)]; me = me.del(t); } return nr; } // 数字数组排序 Array.prototype.sortNum = function(f) { if (!f) f=0; if (f==1) return this.sort(function(a,b){return b-a;}); return this.sort(function(a,b){return a-b;}); } // 获得数字数组的最大项 Array.prototype.getMax = function() { return this.sortNum(1)[0]; } // 获得数字数组的最小项 Array.prototype.getMin = function() { return this.sortNum(0)[0]; } // 数组第一次出现指定元素值的位置 Array.prototype.indexOf = function(o) { for (var i=0; i=0; i--) re = re.del(rs[i]); return re; } function markAjax(file,Methods,fun,loading,data){ if(!Methods){Methods="post"} if(typeof(loading)=="string"){ var w var img=new element("img"); img.src=loading; img.onload=function(){ img.onload="null"; w=new win(img.width,img.height); w.bg.style.backgroundColor="#ffffff"; w.bg.style.display="none"; w.iframe.innerHTML=""; img.addlast(w.iframe); ajax(); } } else{ ajax(); } function ajax(){ try{ var ohttp=new XMLHttpRequest(); } catch(e){ try{ var ohttp=new ActiveXObject("microsoft.XMLHTTP"); } catch(ee){ var ohttp=new ActiveXObject("msxml2.XMLHTTP"); } } ohttp.onreadystatechange=function(){ if(ohttp.readyState==4){ if(ohttp.status==200){ try{w.close()}catch(e){} if(fun){ fun(ohttp); } else{ alert("not function!/n"+ohttp.responseText); } } else{ alert("not file!"); try{w.close()}catch(e){} } } } ohttp.open(Methods,file,"false"); ohttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); ohttp.send(data); } } /* var styles={ width:"200px", height:"200px", backgroundColor:"#00ff00", color:"#ffffff" } var atts={ title:"0123456789", innerHTML:"0123456789", onclick:function(){ this.addcss(styles2); } } var Layer1=new node("Layer1");//这个构造函数 可以以ID 和DOM对象作为参数 var div=new element("div");//这个构造函数 以TAGNAME 作为参数 //DOM增强类 Layer1.remove();//删除这个节点 Layer1.addfirst();//添加参数节点的第一 Layer1.addlast();//添加参数节点的最后 Layer1.addback(Layer2);//添加参数节点的后面 Layer1.addfront(Layer2);//添加参数节点的前面 Layer1.addcss(styles);//为这个接点增加CSS对象 Layer1.addatts(atts);//为这个节点增加属性对象 Layer1.getstyle();//获取这个节点的计算样式 Layer1.hide(1000,50,fun);//1秒的时间逐渐隐藏这个节点 Layer1.show(1000,50,fun);//1秒的时间逐渐显示这个节点 Layer1.setop(0.5);//设置元素透明度 Layer1.getop();//获取元素透明度 Layer1.addEvent(s,f);//第一个参数是要增加的事件 第2个参数是 function函数 Layer1.removeEvent(s,f);//第一个参数是要删除的事件 第2个参数是 function函数 Layer1.addClass();//增加类; Layer1.removeClass();//删除类; Layer1.getElementsByClass(className);//返回有className的元素数组; Layer1.previousElement();//返回前面的元素; Layer1.nextElement();//返回后面的元素; 自定义窗口类: var w=new win("111231.html",500,500);//这个构造函数 1是要打开的页面 2 3 是宽高 w.bg w.iframe w.close();//本方法关闭窗口 navigator类: //以下7个函数根据浏览器的不同返回true或者false isie(); isie8(); isie7(); isie6(); isie5(); issf(); isff(); isop(); location类: //返回根目录 base_url(); load类: 分别动态载入JS和CSS文件 loadJS("1.js"); loadCSS("1.css"); markAjax("1.php","post",f,"loading.gif","data=123123"); */