中山php|最优网络中山做网站 中山php建站

最优良人

Posts Tagged With: js

异步加载可视化编辑器 Xheditor

2011/08/15 at 01:02 » Comments (6)

如果像上一篇文章使用基于Jquery的可视化编辑器 Xheditor 那样设置的话,访问页面时会加载70多k的jquery文件和50多k的xheditor文件,为了追求页面默认加载的性能提升,其实这些文件完全可以在编辑的时候异步加载的,下面是操作步骤: 1,需要用到一个异步加载js文件并执行的函数 function getJsFile(url, callBack){ var XH = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject('Msxml2.XMLHTTP'); XH.open('get',url,true); XH.onreadystatechange = function(){ if(XH.readyState == 4 && XH.status == 200){ if(window.execScript) window.execScript(XH.responseText); else eval.call(window, XH.responseText); eval(callBack); } ...more »

JS判断一个变量是否是数组以及循环数组

2011/08/14 at 02:52 » Comments (7)

JS判断一个变量是否是数组的方法 function isArray(o) { return Object.prototype.toString.call(o) === '[object Array]'; } //for in循环数组 var key; for (key in array) { } //for循环数组 var key; for (key =0;key< url.length;key++) { } more »

常用JS语句

2011/08/14 at 01:20 » Comments (277)

//显示与隐藏 document.getElementById('s1').style.display=''; //js返回上次页面 window.history.back(); history.go(-2); //隔一段时间执行一次函数 intervalID = setInterval("showTime()", 5000); //延迟一段时间执行函数 timeoutID = setTimeout("showTime()", 5000); // 停止: 主要是利用 window.clearInterval(intervalID); window.clearTimeout(timeoutID); //表单提交 name.submit()或者javascript:this.submit()(必须处在form表单内) //取得id document.getElementById("bbac").value more »