获取html中的节点
document.getElementById("header");
获取window尺寸方法(获取的是当前窗口的大小,小于或等于用户可用浏览器的大小):
document.documentElement.clientHeight
document.documentElement.clientWidth
或者
document.body.clientHeight
document.body.clientWidth
实用的 JavaScript 方案(涵盖所有浏览器):
var w=window.innerWidth //与上面一样的效果
var h=window.innerHeight
其他 Window 方法
window.open() // 打开新窗口
window.close() //关闭当前窗口
window.moveTo() //移动当前窗口
window.resizeTo() //调整当前窗口的尺寸
Window Screen 可用高度
screen.availHeight //获取的是当前用户浏览器可用的宽高
screen.availWidth
window.location
对象用于获得当前页面的地址 (URL),并把浏览器重定向到新的页面。
location.hostname //返回 web 主机的域名
location.pathname //返回当前页面的路径和文件名
location.port //返回 web 主机的端口 (80 或 443)
location.protocol //返回所使用的 web 协议(http: 或 https:)