JS DOM(ドキュメントオブジェクトモデル)とBOM(ブラウザオブジェクトモデル)
4471 ワード
JSではDOM(Document Object Model)オブジェクトとBOM(Browser Object Model)オブジェクトの操作が重要な内容である.DOMは主にHTMLノードの操作、CSSの操作、HTMLイベントの傍受と処理などのHTMLドキュメントの属性と方法を含む.BOMには、ブラウザに関連するプロパティやメソッドは含まれません.
DOM知識ポイント1、ページの要素と属性を変更する
2、ページ要素のスタイルを変更する
3、ページ要素イベントの傍受と処理によく使われるイベント:
BOM知識ポイント
DOM知識ポイント1、ページの要素と属性を変更する
a、 :
document.getElementById()
document.getElementsByTagName()
document.getElementsByClassName()
b、js HTML
document.write();
c、 :
document.getElementById(id).innerHTML
document.getElementById(id).innerHTML=new HTML;
d、 :
document.getElementById(id).getAttribute(attribute)
document.getElementById(id).setAttribute(value);
e、 html :document.createElement
f、 html :document.createTextNode
g、 :document.appendChild();
h、 :parent.removeChild(child)
2、ページ要素のスタイルを変更する
a、 css :
document.getElementById(id).style.property;//
document.getElementById(id).style.property=new style;
document.getElementById(id).getComputedStyle;// ,IE9 , null,IE9 currentStyle 。
3、ページ要素イベントの傍受と処理によく使われるイベント:
onload:
onblur:
onfocus:
onchange:
onsubmit:
onkeydown:
onkeypress:
onkeyup:
onclick:
ondblclick:
onmousedown:
onmousemove:
onmouseout:
onmouseover:
onmouseup:
onabort:
BOM知識ポイント
a、
window.open():
window.close():
window.moveTo():
window.resizeTo():
b、
:
window.innerHeight
window.innerWidth
Internet Explorer 8、7、6、5:
document.documentElement.clientHeight document.body.clientHeight
document.documentElement.clientWidth document.body.clientWidth
c、
screen.availWidth:
screen.availHeight:
d、
location.hostname:web
location.pathname:
location.port: (80 443)
location.protocol: web (http:// https://)
history.back():
history.forward():
e、
navigator.appVersion:
navigator.platform:
navigator.userAgent: User-agent header
f、
setInterval() clearInterval /
setTimeout clearTimeout() ( )/