Time of Update: 2017-01-13
費話少說看代碼!<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><TABLE class=clsSysTab cellSpacing=0 borderColorDark=#ccffcc cellPadding=0 width="100%" align=center borderColorLight=#396942 border=1&
Time of Update: 2017-01-13
以前做過一個,沒考慮四捨五入,現在把代碼改進了一下,如下:/***********************************************************Function formatnumber(value,num)Written by zerglingjavascript版本的FormatNumber函數,用法與VBScript相同,第一個參數是待格式化的數值,第二個是保留小數位元注意:返回的是字串類型第一個函數需要調用第二個函數,所以第二個不能去掉*********
Time of Update: 2017-01-13
/********************************************************************************** EO_JSLib.js* javascriptRegex檢驗**********************************************************************************//
Time of Update: 2017-01-13
八. 綜合應用 最後一個例子示範JavaScript對象的重要性。首先設定好一個 Calendar(日曆)對象,然後根據需要顯示任何一個月的月曆。執行過程不複雜,只需要指定月和年為對象屬性,然後讓構造器做其它事情即可:<script language="JavaScript">/* Calendar object, calendar.js Usage: obj = new Calendar(mm, yyyy); created 15.Mar.2001
Time of Update: 2017-01-13
五. 對象應用常式 再示範另一個關於Thermometer(溫度計)對象的例子,它負責將不同的溫度刻度進行轉換:<script language="JavaScript">// constructorfunction Thermometer(degrees, scale){// methodsthis.convertToCelsius = convertToCelsius;this.convertToFahrenheit =
Time of Update: 2017-01-13
使用JavaScript改進你的架構
Time of Update: 2017-01-13
請看下面用javascript設定和讀取cookie的簡單例子,現在的問題是,如果要設定的是一個cookie集,比如在cookie1集中有uname,uid兩組資訊,應該如何寫呢?cookie("cookie1")("uname")="testuser"cookie("cookie1")("uname")="testuid"---------------------------
Time of Update: 2017-01-13
js的範圍是有函數劃分的,而不是塊兒,所以js範圍分為全域範圍和局部範圍(函數範圍)。所有屬於全域範圍的變數都是window對象的屬性js變數有一個很重要的概念,範圍鏈看一個例子分析一下var str1 = 'global'; function t1() { console.log(str1); // <span style="color:
Time of Update: 2017-01-13
在寫項目的時候,要實現一個數組記錄上下移動的樣本。寫起來也沒有沒麻煩,無非是交換數組元素。最終實現代碼如下,比較重要的是那個函數。// 交換數組元素 var swapItems = function(arr, index1, index2) { arr[index1] = arr.splice(index2, 1,
Time of Update: 2017-01-13
之前已經寫了利用window.name來跨域傳輸資料,location.hash方法的原理也類似,同樣是利用location.hash改變後不會重新整理的特徵,通過引用外域的資料頁面修改首頁面的location.hash來達到傳輸資料的目的。同樣是三個頁面:111cn.net /main.html(首頁面)、111cn.net /proxy.html(被代理頁面)、b.com/data.html(外域的資料頁面)1.本域首頁面main.html的代碼var iframe =
Time of Update: 2017-01-13
console.log('[] == []是:'+([] == [])); //falseconsole.log('[] === []是:'+([] === [])); //falseconsole.log('{} == {}是:'+({} == {})); //falseconsole.log('{} === {}是:'+({} === {})); //false //trueconsole.log( '[] == !{}是:'+([] == !{} ));
Time of Update: 2017-01-13
假設有這樣一個動畫功能需求:把一個div的寬度從100px變化到200px。寫出來的代碼可能是這樣的: 代碼如下複製代碼 <div id="test1" style="width: 100px; height: 100px; background: blue; color: white;"></div>function animate1(element, endValue, duration)
Time of Update: 2017-01-13
對於json格式的字串,在使用eval將字串轉換為json對象時需要注意在前後加上小括弧。如下所示:<script type="text/javascript"> var data = '{root:[{name:"1", value:"0"},{name:"6101", value:"北京"},{name:"6102",
Time of Update: 2017-01-13
jsDatePick是一個免費的日期選擇JavaScript外掛程式,一個日曆控制項彈出層,可以用到網頁上也可以用在網頁的APP上,jsdatepick是一個JavaScript日期選取器,使用DOM技術產生的HTML代碼。閱讀下面的例子和文檔,在幾分鐘內,你可以在你的網站有一個彈出式日期選擇的解決方案。閱讀下面的參數的完整的文檔,並下載jsdatepick。我們開發了jsdatepick作為自訂日期選擇模組為我們的網路資金管理軟體-檢查出來,如果你喜歡。所有參數useMode
Time of Update: 2017-01-13
Mocha是JavaScript/Nodejs的一個非常優秀的測試架構,本身就支援同步和非同步測試,不過,非同步測試由於要顯式調用done(),容易造成非同步代碼callback嵌套過深,不利於看懂和維護測試代碼:it('async test', function(done) { doSomethingA(function (err, r1) { &nb
Time of Update: 2017-01-13
本js代碼通過對js對象進行各方面的比較來判斷兩個對象是否相等cmp = function( x, y ) { // If both x and y are null or undefined and exactly the same if ( x === y ) { return true; } // If they are not strictly equal, they both need to be Objects if ( ! ( x instanceof
Time of Update: 2017-01-13
方法一var myreg = /^([a-za-z0-9]+[_|_|.]?)*[a-za-z0-9]+@([a-za-z0-9]+[_|_|.]?)*[a-za-z0-9]+.[a-za-z]{2,3}$/; if(!myreg.test(document.adddata.email.value)) { alert("email is wrong!"); &
Time of Update: 2017-01-13
<head><meta http-equiv="content-type" content="text/html; charset=gb2312" /><title>javascript教程過濾html標籤代碼</title><script language= "javascript "> <!--function setcontent()
Time of Update: 2017-01-13
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.111cn.net/ 1999/xhtml"><head><meta
Time of Update: 2017-01-13
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.111cn.net/ 1999/xhtml"><head><meta