IE, Safari, Opera, and Chrome all provide screenLeft and screenTop properties that indicate the window's location in relation to the left and top of the screen, respectively. Firefox provides this functionality through the screenX and screenY, which are also supported in Safari and Chrome. Opera supported screenX and screenY, but you should avoid using them in Opera, because they don't correspond to screenLeft and screenTop. The following code determines the left and top positions of the window across browsers:

 var leftPos = (typeof window.screenLeft == "number")? window.screenLeft : window.screenX;
var topPos = (typeof window.screenTop == "number")? window.screenTop : window.screenY;

  This example uses the ternary operator to determine if the screenLeft and screenTop properties exist. If they do(which is the case in IE, Safari, Opera, and Chrome), they are used. If they don't exist(as in Firefox), screenX and screenY are used.

  There are some quirks to using these values. In Internet Explorer, Opera, and Chrome, screenLeft and screenTop refer to the space from the left and top of the screen to the page view area represented by window. If the window object is the topmost object and the browser window is at the very top of the screen(with a y-coordinate of 0), the screenTop value will be the pixel height of the browser toolbars that appear above the page view area. Firefox and Safari treate these coordinates as being related to the entire browser window, so placing the window at y-coordiate 0 on the screen returns a top position of 0.

  

Window Position的更多相关文章

  1. LeetCode题解-----Sliding Window Maximum

    题目描述: Given an array nums, there is a sliding window of size k which is moving from the very left of ...

  2. [LeetCode] Sliding Window Maximum 滑动窗口最大值

    Given an array nums, there is a sliding window of size k which is moving from the very left of the a ...

  3. 239. Sliding Window Maximum *HARD* -- 滑动窗口的最大值

    Given an array nums, there is a sliding window of size k which is moving from the very left of the a ...

  4. javascript position兼容性随笔

    一.Javascript源码 if (!window.jasen.core.Position) { window.jasen.core.Position = {}; } function Size(w ...

  5. POJ 2823 Sliding Window + 单调队列

    一.概念介绍 1. 双端队列 双端队列是一种线性表,是一种特殊的队列,遵守先进先出的原则.双端队列支持以下4种操作: (1)   从队首删除 (2)   从队尾删除 (3)   从队尾插入 (4)   ...

  6. POJ 2823 Sliding Window 题解

    POJ 2823 Sliding  Window 题解 Description An array of size n ≤ 106 is given to you. There is a sliding ...

  7. POJ 2823 Sliding Window

    Sliding Window Time Limit: 12000MSMemory Limit: 65536K Case Time Limit: 5000MS Description An array ...

  8. POJ2823 Sliding Window

    Time Limit: 12000MS   Memory Limit: 65536K Total Submissions: 53086   Accepted: 15227 Case Time Limi ...

  9. POJ2823Sliding Window

    Sliding Window Time Limit: 12000MS   Memory Limit: 65536K Total Submissions: 49919   Accepted: 14391 ...

随机推荐

  1. R树--理解平面思维

    R树数据结构 备注:参考wiki的内容. 简介 Guttman, A.; “R-trees: a dynamic index structure for spatial searching,” ACM ...

  2. string::substr

    string substr (size_t pos = 0, size_t len = npos) const; #include <iostream> #include <stri ...

  3. java中int转成String位数不足前面补零

    java中int转成String位数不足前面补零 转载自:http://ych0108.iteye.com/blog/2174134 java中int转String位数不够前面补零 String.fo ...

  4. .Net界面开发神器—DevExpress官方汉化包免费下载!还在等什么?

    点击获取DevExpress v19.1.7新版试用下载 DevExpress Localization Service允许您创建一组自定义的附属程序集,要将语言包添加到程序集中,请查看本文中为大家列 ...

  5. idea的maven项目运行出错_java.io.FileNotFoundException: class path resource [spring/sprint-tx.xml] cannot be opened because it does not exist

    前提:idea  maven  ssm 错误信息如下: 严重: Exception sending context initialized event to listener instance of ...

  6. 给PS添加ICO格式文件

    为什么你的ps不能直接打开favicon.ico文件呢?因为你没有安装识别ico的格式插件. 安装步骤如下: 下载格式文件:https://pan.baidu.com/s/1lE0El1VtDqD5l ...

  7. BZOJ 3060: [Poi2012]Tour de Byteotia 并查集

    前 $k$ 个节点形成的结构必定是森林,而 $[k+1,r]$ 之间肯定是都连上,而剩下的一个在 $[1,k],$一个在 $[k+1,r]$ 的节点就能连多少连多少即可. Code: #include ...

  8. vue模板语法下集

    1. 样式绑定 1.1 class绑定 使用方式:v-bind:class="expression" expression的类型:字符串.数组.对象 1.2 style绑定 v-b ...

  9. 笔记本在安装Windows+Linux双系统后,进入Windows时花屏的解决办法

    问题:在笔记本安装双系统(Windows7+Ubuntu14.04)[先安装Windows,后安装Ubuntu]后,进入Windows时出现了花屏. 问题原因:笔记本只有集显,在系统启动时会先加载Ub ...

  10. [Ubuntu]更改所有子文件和子目录所有者权限

    https://www.linuxidc.com/Linux/2015-03/114695.htm change mode -> chmod change owner -> chown 1 ...