類(lèi)型轉(zhuǎn)換:parseInt\parseFloat\toString
類(lèi)型判斷:typeof;eg:if(typeof(var)!="undefined")\isNaN
字符處理函數(shù):toLowerCase\touppercase\
substring(從哪里截到哪)\substr(從哪里開(kāi)始;截多少個(gè)字符) \indexOf(字串中找某串字符)\replace(替換函數(shù))\
charCodeAt
concat
split
join
定時(shí)處理函數(shù):setInterval;setTimeout;clearTimeout;clearInterval
兩個(gè)顯示控制屬性:visibility(hidden,hide,show,visible);display(none,block,inline)
編碼的一些函數(shù):escape();
取得對(duì)象的方法:
document.getElementsByTagName(根據(jù)標(biāo)簽名獲得對(duì)象組)\
document.getElementsByTagName('head').item(0)
document.getElementsByName(通過(guò)NAME獲得對(duì)象)\
document.getElementById(通過(guò)ID獲得對(duì)象)\
document.form1.f1\
document.all.tags(t)[id]
document.all[id]
document.layers[id]
不常用的一些方法:
moveToAbsolute:
fromElement
toElement
contains
captureEvents
parent.frames
moveTo(x,y)
resizeBy(x,y)
resizeTo(x,y)
attachEvent('onmousedown',showHide);
document.createElement('')
document.createTextNode('')
obj.setAttribute('src','')
obj.getAttribute('')
event.srcElement
style.cssText
document.body.appendChild
document.body.removeChild
document.body.insertAdjacentHTML("AfterBegin",s)
innerHTML/
removeNode
insertBefore
arguments
event.keyCode
正則相關(guān):RegExp(eg:new RegExp("\"","g"))
一些長(zhǎng)寬及位置屬性:
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.onerror=function(){return true;}隱去報(bào)錯(cuò)
window.onload\window.onunload
window.status
window.parent.location.href
window.location.href
window.top.location.href
數(shù)學(xué)方法:
Math.max
數(shù)組方法:
length
slice
JS輸出方法:
document.write(s);
alert(s);
confirm
prompt
document.writeln
彈窗方法:
window.showModalDialog(<url>,<標(biāo)題>,<屬性>)
window.open("","","");
附:常用DOM方法和屬性(即必須掌握部分)
創(chuàng)建節(jié)點(diǎn):createElement();createTextNode()
復(fù)制節(jié)點(diǎn):cloneNode()
插入節(jié)點(diǎn):appendChild();insertBefore()
刪除節(jié)點(diǎn):removeChild()
替換節(jié)點(diǎn):replaceChild()
設(shè)置節(jié)點(diǎn)屬性:setAttribute()
查找節(jié)點(diǎn):getAttribute();getElementById();getElementsByTagName();hasChildNodes
節(jié)點(diǎn)的屬性:nodeName;nodeType;nodeValue
遍歷節(jié)點(diǎn)樹(shù):childNodes;firstChild;lastChild;nextSibling;parentNode;previousSibling