型別轉換:parseint\parsefloat\tostring
型別判斷:typeof;eg:if(typeof(var)!="undefined")\isnan
字元處理函式:tolowercase\touppercase\
substring(從**截到哪)\substr(從**開始;截多少個字元) \indexof(字串中找某串字元)\replace(替換函式)\
charcodeat
concat
split
join
定時處理函式:setinterval;settimeout;cleartimeout;clearinterval
兩個顯示控制屬性:visibility(hidden,hide,show,visible);display(none,block,inline)
編碼的一些函式:escape();
取得物件的方法:
document.getelementsbytagname(根據標籤名獲得物件組)\
document.getelementsbytagname('head').item(0)
document.getelementsbyname(通過name獲得物件)\
document.getelementbyid(通過id獲得物件)\
document.form1.f1\
document.all.tags(t)[id]
document.all[id]
document.layers[id]
正則相關:regexp(eg:new regexp("\"","g"))
一些長寬及位置屬性:
window.innerheight
window.innerwidth
document.documentelement.clientwidth
document.documentelement.clientheight
document.body.clientwidth
document.body.clientheight
document.body.offsetwidth
document.body.offsetheight
document.body.scrollleft
document.body.scrolltop
document.location.reload()
window一些方法:
window.οnerrοr=function()隱去報錯
window.onload\window.onunload
window.status
window.parent.location.href
window.location.href
window.top.location.href
數學方法:
math.max
陣列方法:
length
slice
js輸出方法:
document.write(s);
alert(s);
confirm
prompt
document.writeln
彈窗方法:
window.showmodaldialog(,《標題》,《屬性》)
window.open("","","");
附:常用dom方法和屬性(即必須掌握部分)
中企速聯
js中的常用函式整理
隨機數生成器 math.random 裝換為整數 parseint 日期時間函式 需要用變數呼叫 var b new date 獲取當前時間 b.gettime 獲取時間戳 b.getfullyear 獲取年份 b.getmonth 1 獲取月份 b.getdate 獲取天 b.gethours 獲...
常用js整理
intege 1 9 d 整數 intege1 1 9 d 正整數 intege2 1 9 d 負整數 num d d 數字 num1 0 9 0 9 1 9 0 9 0 9 1 9 0 9 0 9 0 9 1 9 0 9 正數 包括浮點和整數 num2 1 9 d 0 負數 負整數 0 decma...
常用js整理
intege 1 9 d 整數 intege1 1 9 d 正整數 intege2 1 9 d 負整數 num d d 數字 num1 0 9 0 9 1 9 0 9 0 9 1 9 0 9 0 9 0 9 1 9 0 9 正數 包括浮點和整數 num2 1 9 d 0 負數 負整數 0 decma...