JavaScript ? - ???? ?? ??
???? ?? ??(BOM)
???? ?? ??(BOM)? ?? ???? ??? ????.
?? ????? JavaScript ?? ??? ?? (??) ??? ??? ? ??? ???? ??? ?? BOM?? ???? ??? ? ?????.
window ??
????? ??? ?? ? ??? ?????. ?, ? ??? ?????? ?? ?? ?????.
? ??? ?? ????, ?? ??? ?? ??? ??? ? ????. ?? ?? window.document ?? document? ??? ? ????. ?????, Window.alert() ??? ?? Alert()? ???? ?? ?? ?? ? ??? ???? ??? ??? ? ????.
??? ???? ???? ??? ????? ??? ?? ? ??? ? ???? ?? ?? ? ??? ????.
?: ? ??? ?? ??? ?? ??? ??? ?? ????? ? ??? ?????.
HTML DOM? ??? ? ??? ?? ? ????? ???:
window.document.getElementById("header");
??? ????:
document.getElementById("header") ;
Window Size
???? ?(?? ??? ??? ??? ??? ????? ???)? ??? ???? ? ?? ??? ????.
Internet Explorer, Chrome, Firefox, Opera ? Safari? ??:
window.innerHeight - ???? ?? ?? ??
window.innerWidth - ???? ?? ?? ??
Internet Explorer 8, 7, 6? ?? , 5 :
document.documentElement.clientHeight
document.documentElement.clientWidth
??
document.body.clientHeight
document.body.clientWidth
???? JavaScript ???(?? ????? ??):
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <p id="demo"></p> <script> var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var h=window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; x=document.getElementById("demo"); x.innerHTML="瀏覽器window寬度: " + w + ", 高度: " + h + "。" </script> </body> </html>
?? ? ???
?? ???:
window.open() - ? ? ??
window.close() - ?? ? ??
window.moveTo() - ?? ? ??
window .resizeTo( ) - ?? ? ??? ?????