location对象
location对象是window对象下的一个属性
location可以获取或设置浏览器地址栏的url
history对象
back():回到上一级
forward() 下一级
go():跳转
navigator 对像
userAgent():可以查看当前浏览器的类型
platform():可以查看用户的操作系统类型
偏移量
给两个盒子(都有padding和margin,border)
<div id
="box">
<div id
="son"></div
>
</div
>
<style>
* {
padding: 0
;
margin: 0
;
}
#box {
width: 300px
;
height: 300px
;
border: 5px solid #000
;
padding: 10px
;
margin: 100px
;
}
#son {
width: 100px
;
height: 100px
;
border: 2px solid #ccc
;
padding: 10px
;
margin: 20px
;
}
</style>
offset系列
<script
>
var box
= document
.getElementById('box')
var son
= document
.getElementById('son')
console
.log(box
.offsetTop
);
console
.log(box
.offsetLeft
);
console
.log(box
.offsetWidth
);
console
.log(box
.offsetHeight
);
console
.log(son
.offsetTop
);
console
.log(son
.offsetLeft
);
console
.log(son
.offsetWidth
);
console
.log(son
.offsetHeight
);
</script
>
client系列
console
.log(box
.clientTop
);
console
.log(box
.clientLeft
);
console
.log(box
.clientWidth
);
console
.log(box
.clientHeight
);
scroll系列
console
.log(box
.scrollLeft
)
console
.log(box
.scrollTop
)
console
.log(box
.scrollWidth
)
console
.log(box
.scrollHeight
)