Window-document-javascript
一个浏览器窗口有一个window对象,javascript属于window对象,html为document对象,属于window,body为document对象,只有设置body对象高度为100%,其他地方的高度设置百分比才有效。
html和body本来高度就是0,或者说是auto的。
document.documentElement.offsetHeight,
document.body.offsetHeight都是0
高度根据内容而定,设置为100%就是相对于浏览器窗口window,100%
window.innerHeight与innerWidth获取浏览器窗口内容大小。
做手机Web开发做浏览器兼容用到了,所以在网上找了些汇总下。
alert($(window).height()); //浏览器当前窗口可视区域高度
alert($(document).height()); //浏览器当前窗口文档的高度
alert($(document.body).height());//浏览器当前窗口文档body的高度
alert($(document.body).outerHeight(true));//浏览器当前窗口文档body的总高度 包括border padding margin
alert($(window).width()); //浏览器当前窗口可视区域宽度
alert($(document).width());//浏览器当前窗口文档对象宽度
alert($(document.body).width());//浏览器当前窗口文档body的高度
alert($(document.body).outerWidth(true));//浏览器当前窗口文档body的总宽度 包括border padding margin
Window-document-javascript的更多相关文章
- (function (window, document, undefined) {})(window, document)什么意思?
1.IIFE(即时调用的函数表达式),它采取以下表达式: (function (window, document, undefined) { // })(window, document); Java ...
- (function($, window, document) {}) jQuery 调用解决与其他javascript库冲突的写法
将函数包在红色字体内部,可以解决$符号与其他插件的冲突. <script type="text/javascript"> (function($, window, do ...
- javascript中window,document,body的解释
解释javascript中window,document,body的区别: window对象表示浏览器中打开的窗口,即是一个浏览器窗口只有一个window对象. document对象是载入浏览器的ht ...
- JavaScript的DOM操作。Window.document对象
间隔执行一段代码:window.setlnteval("需要执行的代码",间隔毫秒数) 例 : window.setlnteval("alert("你 ...
- javascript匿名函数自执行 (function(window,document,undefined){})(window,document);
使用匿名自执行函数的作用: (function(window,document,undefined){})(window,document); 1.首先匿名函数 (function(){}) (); ...
- 详解jquery插件中;(function ( $, window, document, undefined )的作用
在jquery插件中我们经常看到以下这段代码 1 2 3 ;(function ( $, window, document, undefined ){ //函数体内具体代码 })(jQuery, wi ...
- 基本的window.document操作及实例
基本的window.document操作及实例 找元素 1.根据id找 var d1 = document.getElementById("d1"); alert(d1); 2.根 ...
- Window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docunme ...
- Window.document对象 轮播练习
Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docun ...
- HTML Window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docunmen ...
随机推荐
- wkhtmktopdf
1: sudo apt-get install wkhtmltopdf 2: sudo apt-get xvfb 3: 切换到root用户: echo 'xvfb-run --server-a ...
- jquery easy ui 的formatter 格式化函数代码
- Quartz.NET文档 入门教程
概述 Quartz.NET是一个开源的作业调度框架,非常适合在平时的工作中,定时轮询数据库同步,定时邮件通知,定时处理数据等. Quartz.NET允许开发人员根据时间间隔(或天)来调度作业.它实现了 ...
- vertex shader(3)
之前我们学习了如何声明顶点着色器.如何设置常量寄存器中的常量.接下来我们学习如何写和编译一个顶点着色器程序. 在我们编译一个顶点着色器之前,首先需要写一个. 有17种不同的指令(instruction ...
- PHP - 脚本退出(包括异常退出),执行指定代码
之前做聊天室的时候有那么个需求就是当用户异常断线的时候就应该清除她的在线状态.因为当时对于flush不够了解,尝试了各种办法,好像都没办法在我们开发机上面执行相应的代码.后来知道是flush的原因.我 ...
- ModleAndView类是干什么的???
/** * 启用账号 */ @SuppressWarnings("finally") @RequestMapping(value = "/accountStart&quo ...
- 查看端口占用情况lsof,并关闭对应进程kill
lsof -n -P| grep ":<端口号>" | grep LISTEN #监听对应端口号的进程 lsof -i tcp:<端口号> #和对应端口号有 ...
- 使用C#通过Oracle.DataAccess连接Oracle,部署时需要注意版本问题
平时我们开发使用的是32位的PC机,所以安装的也是Oracle32位的客户端.但是一般服务器都是64位的,安装的也是64位的Oracle客户端,如果要部署使用Oracle.DataAccess连接Or ...
- Xcode8 问题
ios10 定位问题,在plist中手动添加NSCameraUsageDescription http://www.cocoachina.com/bbs/read.php?tid-1685721.ht ...
- mybaties association 只返回一个结果问题处理
mybatis xml文件为: <resultMap id="BaseResultMap" type="com.test.SubscribeOrder"& ...