標籤:使用 os io 應用 new window
escapse() 編碼函數
escape("(") => %28
unescape() 解碼函數
unescape("%29") => )
eval() 求值函數
eval("11") => 11
isNaN() 數值判斷函數== is not a number
isNaN(0) => false
isNaN("a") => true
isNaN(null) => false
isNaN(undefined) => true
parseInt() 轉成整數函數
parseInt("12") => 12
parseFloat() 轉成浮點數
parseFloat("12.3").toFixed(2); => 12.30
數組
var str = new Array();
var str = new Array([5]);
var str = new Array(1,2,3);
var s1 = new Array(1,2,3);
var s2 = new Array(3,2,1);
concat() 將多個數組結合成一個新的數組
var s3 = s1.concat(s2);
s3 => [1,2,3,3,2,1]
只改變s3,不會改變s1
join() 數組元素結合成一個字串,用特定字元分開
var s4 = s1.join("-");
s4 => "1-2-3"
split() 將字串轉為數組
var s5 = s4.split("-");
s5 => ["1","2","3"]
shift()將數組第一個元素刪除
s1.shift() => [2,3]
pop() 將數組最後一個元素刪除
s1.pop() => [1,2]
push() 放一個元素到數組
s1.push(4) => [1,2,4]
reverse() 反轉
s1.reverse() => [4,2,1]
slice() 將數組內容引入一個新的數組,原數組不變
s1.slice(1) => [2,1]
valueOf() 取得數組內容
s1.valueOf() => [2,1]
布爾對象
1)如果轉換值是null、undefined、0、false均轉為邏輯值false
2)其餘都轉成true
var a = new Boolean(null) => false
var b = new Boolean(true) => true
toString()
a.toString() => "false"
valueOf()
b.valueOf() => true
日期對象
var sysDate = new Date()
sysDate.getYear();
sysDate.getFullYear();
sysDate.getMonth(); 0-11
sysDate.getDate(); 1-31
sysDate.getDay(); 星期數0-6
sysDate.getHours(); 0-23
sysDate.getMinutes(); 0-59
sysDate.getSeconds(); 0-59
sysDate.getMilliseconds(); 特定日的毫秒 0-999
sysDate.getTime(); 特定日期的數值
數學函數
Math.ceil(1.22) => 2
Math.floor(1.22) => 1
Math.round(1.22) => 1
Math.ceil(1.52) => 2
Math.floor(1.52) => 1
Math.round(1.52) => 2
字串對象
var str = new String("abcd");
str => String {0: "a", 1: "b", 2: "c", 3: "d", length: 4}
anchor() 錨點
str.anchor("cc") => "<a name="cc">abcd</a>"
fixed() 固定字
str.fixed() => "<tt>abcd</tt>"
fontsize()
str.fontsize(7) => "<font size="7">abcd</font>"
search()
str.search("b") => 1
視窗對象格式
需要在前面標註window,在許多進階的應用中,可以使用其他別名來替代window
例:當系統中包含多個大小視窗時
opener:表示開啟的當前視窗
parnet:表示上層架構的母視窗
self:表示當前使用中視窗
top:表示最上方的視窗
closed:判斷視窗是否已關閉,傳回值為布爾值
status:代表狀態工具列的臨時性資訊
location:包含當前URL的資訊
parent:代表包含當前視窗或架構組
toolbar:代表瀏覽器的工具列