中山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 »