javascript 获取浏览器高度宽度 页面可视窗体高度宽度
2014-07-19 15:58
435 查看
// 显示区域宽度
var windowWidth = 0;
// 显示区域高度
var windowHeight = 0;
if (self.innerHeight) { // all except Explorer
if (document.documentElement.clientWidth) {
windowWidth = document.documentElement.clientWidth;
} else {
windowWidth = self.innerWidth;
}
windowHeight = self.innerHeight;
} else {
if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else {
if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
}
}
兼容性较好,经得起测试的哦。
var windowWidth = 0;
// 显示区域高度
var windowHeight = 0;
if (self.innerHeight) { // all except Explorer
if (document.documentElement.clientWidth) {
windowWidth = document.documentElement.clientWidth;
} else {
windowWidth = self.innerWidth;
}
windowHeight = self.innerHeight;
} else {
if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else {
if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
}
}
兼容性较好,经得起测试的哦。
相关文章推荐
- Javascript获取页面各种宽度高度(各种浏览器ie6,ie7,firefox下怎么获取更好兼容)
- JavaScript获取屏幕、浏览器、网页高度宽度
- javascript 获取页面高度(多种浏览器)(转)
- JQuery获取窗体可视宽度和高度的方法
- JavaScript获取页面宽度高度大全
- JavaScript获取页面宽度高度大全
- Javascript获取页面宽度,高度,窗口宽度,高度
- javascript 获取滚动条高度+常用js页面宽度与高度
- javascript 获取滚动条高度+常用js页面宽度与高度
- Javascript 获取页面高度(多种浏览器)
- javascript获取浏览器的宽度和高度
- javascript:获取屏幕高度和宽度等信息 & 制作滚动窗体时遇到的问题(转)
- Javascript页面宽度高度的获取方法
- javascript 得到当前页面可视高度和宽度
- Javascript 获取页面高度(多种浏览器)
- javascript 获取页面高度(多种浏览器)
- javascript 获取屏幕,浏览器,网页高度宽度
- Javascript 获取页面高度(多种浏览器)
- javascript 获取页面高度(多种浏览器)(转)
- JavaScript获取页面宽度高度大全