文章專欄 / ARTICLE COLUMN
javascript語法速查表
物件模型
物件 | 方法 | 屬性 | 事件 |
---|---|---|---|
document | close() open(mimeType, "replace") write(html) writeln(html) |
alinkColor anchors[ ] bgColor cookie fgColor forms[ ] lastModified linkColor links[ ] location referrer title vlinkColor |
onClick onDblClick onKeyDown onKeyPress onKeyUp onMouseDown onMouseUp |
links[ ] | hash host hostname href pathname port protocol search target |
onClick onMouseOver |
|
forms[ ] | submit() | action elements encoding method target |
onSubmit |
button | click() | name value |
onClick |
submit | click() | name value |
onClick |
reset | click() | name value |
onClick |
text | focus() blur() select() |
defaultValue name value |
onBlur onChange onFocus onSelect |
textarea | focus() blur() select() |
defaultValue name value |
onBlur onChange onFocus onSelect |
select | blur() focus() |
length name options[ ] selectedIndex |
onBlur onFocus onChange |
option | defaultSelected index length name options selected selectedIndex text value |
||
checkbox | click() | name value checked defaultChecked |
onClick |
radio | click() | checked defaultChecked length name value |
onClick |
password | focus() blur() select() |
name value defaultValue |
|
hidden | name value |
||
navigator | appCodeName appName appVersion mimeTypes[ ] plugins[ ] userAgent |
||
window | alert(message) close() confirm(message) open(url, name, features) prompt(message, inputDefault) setTimeout(statement, delay) clearTimeout(timer) |
defaultStatus frames[ ] length name opener parent self status top window |
onLoad onUnload |
location | reload() replace(url) |
hash host hostname href pathname port protocol search |
|
history | back() forward() go(location) |
length | |
string | anchor(name) big() blink() bold() charAt(index) fixed() fontcolor(color) fontsize(size) indexOf(findString, [startingIndex]) italics() lastIndexOf(findString, [startingIndex]) link(href) small() strike() sub() substring(firstIndex, lastIndex) sup() toLowerCase() toUpperCase() |
length | |
Date | getDate() getDay() getHours() getMinutes() getMonth() getSeconds() getTime() getTimezoneOffset() getYear() parse(datevalue) setDate(dateValue) setHours(hoursValue) setMinutes(minutesValue) setMonth(monthValue) setSeconds(second) setTime(timeValue) setYear(yearValue) toGMTString() toLocaleString() UTC(yearValue, monthValue, dateValue, hoursValue, minutesValue, secondsValue) |
||
Math | abs(number) acos(number) asin(number) atan(number) atan2(y , x) ceil(number) cos(number) exp(number) floor(number) log(number) max(number1, number2) min(number1, number2) pow(number1, number2) random() round(number) sin(number) sqrt(number) tan(number) |
E LN10 LN2 LOG10E LOG2E PI SQRT1_2 SQRT2 |
|
Image | border complete height hspace lowsrc name src vspace width |
onLoad onError onAbor |
內建函數
內建函數 | 可能傳回的資料型態 |
---|---|
escape(string) | 字串("%xx") |
eval(string) | 字串,數目,布林 |
isNaN(test_value) | 布林 |
parseFloat(string) | 浮點數,"NaN",0 |
parseInt(string, base) | 整數 |
unescape(string) | 字串 |
運算子
運算子類別 | 運算子 |
---|---|
算術 | + ++ - -- * / |
字串 | + += |
邏輯 | && || ! |
位元 | & ^ | ~ << >> >>> |
指定 | = += -= *= /= %= &= ^= |= <<= >>= >>>= |
比較 | == != > >= < <= |
特別 | ?: |
運算子的優先次序: ( 最優先執行的運算子排第一 )
運算子類別 | 運算子 |
---|---|
呼叫,會員 | () [] |
反相,增減 | ! ++ -- |
乘除,餘數 | * / % |
加法,減法 | + - |
移位 | << >> >>> |
關係 | < <= > >= |
相等,不等 | == != |
位元 AND | & |
位元 XOR | ^ |
位元 OR | | |
邏輯 AND | && |
邏輯 OR | || |
條件 | ?: |
設定 | = += -+ *= /= %= |
逗號 | , |
保留字(保留字不可以用作變數、函數及物件名稱。)
abstract boolean break byte case catch char class const continue default delete do double |
else extends false final finally float for function goto if implements import in instanceof |
int interface long native new null package private protected public return short static super |
switch synchronized this throw throws transient true try typeof var void while with |