- 浏览: 994753 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (367)
- JavaScript (23)
- Java (60)
- Python (41)
- 其他 (36)
- SQL (4)
- 开发工具 (26)
- Linux (15)
- AJAX (6)
- Cache (3)
- 正则 (4)
- 架构 (9)
- 手机 (3)
- MySQL (4)
- Android (115)
- vps (1)
- 网站 (4)
- scale (3)
- 搜索引擎 (3)
- iPhone (2)
- hessian (1)
- hessdroid (1)
- 411 (1)
- jstat (1)
- gc (1)
- gallery (1)
- 惯性 (1)
- eclipse (1)
- mac wget error (1)
- miui file explorer 无用 解决办法 (1)
- vim (1)
最新评论
-
qingyezhangluo:
哎。楼主您既然是分享代码的为什么要加密的呢?而且问你密码还不回 ...
android应用换皮肤(转) -
MagicError:
kavoe 写道下载文件有密码。。。。
http抓包工具 -
knightdf:
我先试下再来
JAVA的RAS加密例子 -
kavoe:
下载文件有密码。。。。
http抓包工具 -
changanfounder:
hmc1985 写道setCallbackDuringFlin ...
android gallery滑动惯性问题
搞了大半天,总算弄明白了为何用document.body.clientHeight,document.body.offsetHeight都没有办法获取网页可见区域的正确值,原来罪魁祸首是W3C定义的标准!!在新定义出来的标准下 document.documentElement.clientHeight在IE和火狐里都能获取正确值,下面一篇文章详细介绍了获取各种浏览器可见窗口大小这方面的差别:
<script>
function getInfo()
{
var s = "";
s += " 网页可见区域宽:"+ document.body.clientWidth;
s += " 网页可见区域高:"+ document.body.clientHeight;
s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)";
s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)";
s += " 网页正文全文宽:"+ document.body.scrollWidth;
s += " 网页正文全文高:"+ document.body.scrollHeight;
s += " 网页被卷去的高(ff):"+ document.body.scrollTop;
s += " 网页被卷去的高(ie):"+ document.documentElement.scrollTop;
s += " 网页被卷去的左:"+ document.body.scrollLeft;
s += " 网页正文部分上:"+ window.screenTop;
s += " 网页正文部分左:"+ window.screenLeft;
s += " 屏幕分辨率的高:"+ window.screen.height;
s += " 屏幕分辨率的宽:"+ window.screen.width;
s += " 屏幕可用工作区高度:"+ window.screen.availHeight;
s += " 屏幕可用工作区宽度:"+ window.screen.availWidth;
s += " 你的屏幕设置是 "+ window.screen.colorDepth +" 位彩色";
s += " 你的屏幕设置 "+ window.screen.deviceXDPI +" 像素/英寸";
//alert (s);
}
getInfo();
</script>
在我本地测试当中:
在IE、FireFox、Opera下都可以使用
document.body.clientWidth
document.body.clientHeight
即可获得,很简单,很方便。
而在公司项目当中:
Opera仍然使用
document.body.clientWidth
document.body.clientHeight
可是IE和FireFox则使用
document.documentElement.clientWidth
document.documentElement.clientHeight
原来是W3C的标准在作怪啊
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
如果在页面中添加这行标记的话
在IE中:
document.body.clientWidth ==> BODY对象宽度
document.body.clientHeight ==> BODY对象高度
document.documentElement.clientWidth ==> 可见区域宽度
document.documentElement.clientHeight ==> 可见区域高度
在FireFox中:
document.body.clientWidth ==> BODY对象宽度
document.body.clientHeight ==> BODY对象高度
document.documentElement.clientWidth ==> 可见区域宽度
document.documentElement.clientHeight ==> 可见区域高度
?
在Opera中:
document.body.clientWidth ==> 可见区域宽度
document.body.clientHeight ==> 可见区域高度
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)
document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
而如果没有定义W3C的标准,则
IE为:
document.documentElement.clientWidth ==> 0
document.documentElement.clientHeight ==> 0
FireFox为:
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
Opera为:
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
原文地址:http://www.css88.com/article.asp?id=133
判断浏览器的类型:
var ua = navigator.userAgent.toLowerCase ();
var ōs = new Object();
os.isFirefox = ua.indexOf ("gecko") != -1;
os.isOpera = ua.indexOf ("opera") != -1;
os.isIE = !os.isOpera && ua.indexOf ("msie") != -1;
获取浏览器区域的大小://
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){
yScroll = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
yScroll = document.documentElement.scrollTop;
} else if (document.body) {// all other Explorers
yScroll = document.body.scrollTop;
}
return arrayPageScroll;
}
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
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;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
发表评论
-
网站 变灰 兼容各浏览器
2010-08-23 17:28 84<script src="gray ... -
js小技巧
2009-12-10 16:24 1019感谢:http://hi.baidu.com/lundy521 ... -
prototype 1.6
2009-07-08 18:41 828http://www.never-online.net/blo ... -
display:blocK 导致的换行
2009-04-03 19:01 5251#divHeader #divNav #divLogo{mar ... -
jQuery插件---按需加载JavaScript和CSS.
2009-04-02 18:12 4040jQuery插件---按需加载JavaScript和CSS. ... -
JavaScript中的Timer是怎么工作的
2009-03-19 14:35 1434JavaScript中的Timer是怎么 ... -
JS踢掉HTML TAG
2009-02-26 17:31 1011function delHtmlTag(str){ ... -
json 格式化工具
2009-02-20 16:31 2799http://lab.gracecode.com/format ... -
javascript+dom更改html内容总结
2009-02-19 18:01 2351利用JavaScript和dom结合来动态改变HTML内容。1 ... -
IE,firefox内存溢出原因与解决方法
2009-02-18 18:51 4042JavaScript 中的内存泄漏JavaScript 是一种 ... -
网页中嵌入Flash的几种方法(消除IE控件激活虚线)
2009-01-15 15:47 2618Flash 嵌入的问题论坛中有人问了好多次,到底应该怎么用,为 ... -
js压缩
2009-01-13 15:57 1134http://dean.edwards.name/packer ... -
json注意事项
2009-01-11 18:44 12721.JavaScript 用eval 经行转换json数据时。 ... -
Cookie的规范介绍
2009-01-05 16:20 1199Cookie的规范介绍 目前有 ... -
cookie(1)
2009-01-05 16:19 1051我们已经知道,在 document 对象中有一个 cookie ... -
js压缩
2008-12-28 19:26 1250js压缩,既可压缩,又可简单加密 先去这个网站 http:// ... -
用JS访问操作iframe里的dom
2008-12-25 13:41 1680很多人一直都有个想法,要是可以随心所欲的操作iframe就好了 ... -
js飞舞
2008-12-23 15:32 932javascript:R=0; x1=.1; y1=.05; ... -
javascript屏蔽F5刷新键
2008-11-25 13:21 2350<script language="Javas ... -
js 两种继承方法(call prototype)
2008-11-11 14:19 3176<SCRIPT LANGUAGE="JavaS ...
相关推荐
控制屏幕郁闷发泄专家控制屏幕郁闷发泄专家
郁闷时好好发泄的工具
广工《算法和高级数据结构教程课程设计》 郁闷的出纳员(伸展树)C语言实现
WildPackets OmniPeek从入门到郁闷之入门篇.pdf
此软件可以在心情不好的时候运行,砸桌面,在桌面上放虫子,呵呵。
郁闷作业.html
C#郁闷问题解决集合源码 C#郁闷问题解决集合源码 C#郁闷问题解决集合源码
PJBlog2 郁闷的圣诞
形容心情郁闷的话.doc
心情、无聊时可发泄用,比较真实,好玩。还迎使用,谢谢合作!
初中语文文摘社会菲利普亲王的郁闷
谈谈职场上你最郁闷什么.doc
Soluto是一款号称“反郁闷”的系统工具,这家来自以色列的开发方承诺让电脑运行得更好。Soluto可以监视你的PC,发现用户面临的问题。比如打印机问题,导致系统崩溃的软件,过渡消耗资源的程序等。更有意思的是公司还...
郁闷的原始UDP封包,无话说.......................................................
厚着脸皮写这个,希望同志们不要像我这么郁闷,一个GPIO搞了五天,天天测量,天天郁闷,连开发板生意都没有心情做了。 嘿嘿,公司的事情解决,那么就开始6410学习了。
关于很郁闷很失落的心情说说参考.doc
初中语文文摘人生别郁闷根本没人注意你
广工高级算法作业算法和高级数据结构教程课程设计 郁闷的出纳员(伸展树)C语言实现
郁闷了几个小时的Fckeditor动态上传目录配置
jQuery+css3制作郁闷的古瓜脸表情动画特效源码.zip