javascript
JavaScript学习笔记——BOM_window对象
javascript瀏覽器對象模型-windwo對象
BOM Browser Object Model
window對象 是BOM中所有對象的核心。
一、屬性
1.(位置類型-獲得瀏覽器的位置)
IE:
window.screenLeft
可以獲得瀏覽器距屏幕左上角的左邊距
window.screenTop
可以獲得瀏覽器距屏幕左上角的上邊距
FF:
alert(screenX)
alert(screenY)
(獲得瀏覽器的尺寸)
FF:window.innerWidth 獲得窗口的寬度
window.innerHeight 獲得窗口的高度
?
2.關系類型
A.parent返回父窗口
B.top 返回頂層窗口
C.self===window 相當于window
3.stutas 設置窗口狀態欄的文本
window.status="自定義的狀態欄文字"
二、方法
1.窗體控制
A.對窗體的移動
window.moveBy(x,y) 相對于當前位置沿著X\Y軸移動指定的像素,如負數是反方向
moveTo(x,y) 相對于瀏覽器的左上角沿著X\Y軸移動到指定的像素,如負數是反方向
B.窗體尺寸的改變
resizeBy(x,y) 相對于當前窗體的大小,調整寬度和高度
resizeTo(x,y) 把窗體調整為指定寬度和高度
2.對窗體滾動條的控制
scrollBy(x,y) 相對于當前滾動條的位置移動的像素(前提有滾動條)
scrollTo(x,y) 相對于當前窗口的高度或寬度,移動到指定的像素
3.時間間隔的函數
setInterval("函數或者代碼串",指定的時間(毫秒)) 按照指定的周期(毫秒)不斷的執行函 數或是代碼串
// setInterval("函數或者代碼串",指定的時間(毫秒)) 按照指定的周期(毫秒)不斷的執行函 數或是代碼串//第一種調用方式// setInterval("alert('后盾網')",1000);\ // var i=0 // setInterval(changes,1000) // function changes () { // alert(i) // i++ // }//第二種調用方式 //var a=0; //setInterval(function () { // alert(a); // a++ //},1000)//第三種調用方式//var i=0; // setInterval("changes(0)",1000) // function changes (i) { // alert(i) // i++ // }clearInterval()
//停止調用 window.onload=function () {var t=setInterval('alert("后盾網")',5000)var aa=document.getElementById("stop");aa.onclick=function () {clearInterval(t)}} <input type="button" value="停止" id="stop"> setTimeout("函數或者代碼串",指定的時間(毫秒)) 在指定的毫秒數后只執行一次函數或代碼。
clearTimeout()
?
4.打開新的窗口
open(url,name,feafurse,replace) 通過腳本打開新的窗口
window.οnlοad=function () {var names=document.getElementById("names");var but=document.getElementById("but");but.onclick=function () {open("26.1.html","windows","status=0,menubar=0,toolbar=0")}}?
?
?
?
?
轉載于:https://www.cnblogs.com/tonglin0325/p/4713925.html
總結
以上是生活随笔為你收集整理的JavaScript学习笔记——BOM_window对象的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 记一个简单的保护if 的sh脚本
- 下一篇: poj - 3254 Corn Fiel