除IE外的浏览器查看窗口大小和位置信息:
//The overall size of the browser window on the desktop var windowWidth = window.outerwidth;
var windowHeight = window.outerHeight; //This is the position of the browser window on the desktop
var windowX = window.screenX;
var windowY = window.screenY; //The size of the viewport in which the HTML document is displayed
//This is the window size minus the menu bars,toolbars,scrollbars,etc.
var viewportWidth = windows.innerWidth;
var viewportHeight = windows.innerHeight; //These values specify the horizontal and vertical scrollbar positions.
//They are used to convert between document coordinates and window coordinates.
//These values specify what part of the document appears in the upper-left corner of the screen.
var horizontalScroll = window.pageXOffset;
var verticalScroll = window.pageYOffset;
------------------------------------------------------------------
var x=window.screenLeft?window.screenLeft: window.screenX ;
var y=window.screenTop?window.screenTop: window.screenY;
alert(x+" "+y);
网页可见区域宽:document.body.clientWidth
网页可见区域高:document.body.clientHeight
网页可见区域宽:document.body.offsetWidth (包括边线的宽)
网页可见区域高:document.body.offsetHeight (包括边线的宽)
网页正文全文宽:document.body.scrollWidth
网页正文全文高:document.body.scrollHeight
网页被卷去的高:document.body.scrollTop
网页被卷去的左:document.body.scrollLeft
网页正文部分上:window.screenTop
网页正文部分左:window.screenLeft
屏幕分辨率的高:window.screen.height
屏幕分辨率的宽:window.screen.width
屏幕可用工作区高度:window.screen.availHeight
屏幕可用工作区宽度:window.screen.availWidth HTML精确定位: scrollLeft,scrollWidth,clientWidth,offsetWidth
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置
offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置
event.clientX 相对文档的水平座标
event.clientY 相对文档的垂直座标
event.offsetX 相对容器的水平坐标
event.offsetY 相对容器的垂直坐标
document.documentElement.scrollTop 垂直方向滚动的值
event.clientX+document.documentElement.scrollTop 相对文档的水平座标+垂直方向滚动的量 IE,FireFox 差异如下: IE6.、FF1.+: clientWidth = width + padding clientHeight = height + padding offsetWidth = width + padding + border offsetHeight = height + padding + border IE5./5.5:
clientWidth = width - border clientHeight = height - border offsetWidth = width offsetHeight = height (CSS中的margin属性,与clientWidth、offsetWidth、clientHeight、offsetHeight均无关) function resize(){
var win = Ext.fly('窗体对象组件');//获得要调整的窗体,注意这里先用Ext.fly的方式来获取组件 ,如果不行再换别的,如getCmp,get等
//然后参考 http://www.javaeye.com/topic/155981 这篇博客,来动态设定组件的大小
}
window.onresize = resize; Ext.onReady(function(){
resize();
} Ext.onReady(function(){
formWindow = new Ext.Window({
layout:'fit',
width:,
height:,
resizable:true,
closeAction:'close',
plain: true,
maximizable: true,
// minimizable : true, // 最小化
listeners: {
close:function(w){
//关键部分:关闭窗口前先还原,滚动条才不会消失
w.restore();
},
maximize:function(w){
//关键部分:最大化后需要将窗口重新定位,否则窗口会从最顶端开始最大化
w.setPosition(document.body.scrollLeft-,document.body.scrollTop- );
}
}
});
formWindow.show();
})

js之获取窗口大小和位置信息的更多相关文章

  1. C# 图像处理: 获取当前活动窗口句柄,获取窗口大小及位置

    需调用API函数 需在开头引入命名空间 using System.Runtime.InteropServices; 获取当前窗口句柄:GetForegroundWindow() [DllImport( ...

  2. QT获取窗口大小和位置等信息

    QT窗口尺寸,窗口大小和大小改变引起的事件 QResizeEvent. 来源:http://blog.csdn.net/dbzhang800/article/details/6741344?reloa ...

  3. 获取用户当前位置信息的两种方法——H5、微信

    在之前的 调用百度地图API的总结 中获取当前位置信息我用的是 H5 ,其实微信也提供了获取用户地理位置的方法,现将这两种方法都贴出来,看情况选择使用. 一.H5 获取当前地理位置得到经纬度 // H ...

  4. 淘宝(新浪)API获取IP地址位置信息

    package com.parse; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IO ...

  5. PHP 获取IP地址位置信息「聚合数据API」

    聚合数据 提供了[查询IP所属区域]的服务接口,只需要以 GET 请求的方式向 API 传入 IP地址 和 APPKEY 即可获得查询结果. 这里的难点主要在于如何通过PHP获取客户端IP地址,以及如 ...

  6. 【easyui】--普通js中获取easyui中分页信息(page,pageSize等)

    对于datagrid,获取其分页信息: 方法: var pageopt = $('#list_data').datagrid('getPager').data("pagination&quo ...

  7. 关于tomcat7服务下面js无法获取JSESSIONID的cookie信息

    http://tomcat.apache.org/tomcat-5.5-doc/config/context.html Does anyone know what changed in the con ...

  8. (转)linux如何获取鼠标相对位置信息

    #include <stdio.h> #include <stdlib.h> #include <linux/input.h> #include <fcntl ...

  9. html5获取位置信息,h5获取位置信息

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

随机推荐

  1. Localstorage本地存储兼容函数

    前言HTML5提供了本地存储的API:localstorage对象和sessionStorage对象,实现将数据存储到用户的电脑上.Web存储易于使用.支持大容量(但非无限量)数据同时存储,同时兼容当 ...

  2. 攻城狮在路上(壹) Hibernate(十三)--- Hibernate的检索方式(上)

    Hibernate提供了以下几种检索对象的方式: A.导航对象图检索方式. B.OID检索方式.Session.get() load(); C.HQL检索方式.Query. D.QBC检索方式.Que ...

  3. .NET Nancy 详解(二) 简易路由实现

    继续上面的简易版本,有意思的点剩下便是路由实现了. 路由注册 首先,来看一下基本的路由注册过程. public FakeNancyModuleWithoutBasePath() { Delete[&q ...

  4. AndroidStudio创建新项目报错

    创建新项目自动执行时报错: Failed to import new Gradle project: failed to find Build Tools revision 17.0.0 Consul ...

  5. document.body / document.ducumentElement /等获取高度和宽度的区别 ----转载

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  6. 【框架】网络请求+Gson解析--Retrofit 2

    其实内部是封装了Okhttp和Gson解析 public class CourseFragmentAPI { public static void get(String userId, BaseCal ...

  7. Spring常用工具类

    Spring框架下自带了丰富的工具类,在我们开发时可以简化很多工作: 1.Resource访问文件资源: 具体有: ResourceUtils.getFile(url); FileSystemReso ...

  8. 关于JSP页面字段属性设为disabled或者readonly所带来的问题总结

    最近需要将页面一些自动求和的字段设为不可操作,当然disabled和readonly都可以实现,但是我的页面需求是来录入数据的,当用disabled时,该字段值是无法被获取并传到后台的,这时如果使用r ...

  9. hive streaming 使用shell脚本

    一.HIVE streaming 在Hive中,需要实现Hive中的函数无法实现的功能时,就可以用Streaming来实现.其原理可以理解成:用HQL语句之外的语言,如Python.Shell来实现这 ...

  10. 疯狂java学习笔记之面向对象(三) - 方法所属性和值传递

    方法的所属性: 从语法的角度来看:方法必须定义在类中 方法要么属于类本身(static修饰),要么属于实例 -- 到底是属于类还是属于对象? 有无static修饰 调用方法时:必须有主调对象(主语,调 ...