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. JS 获取和返填单选按钮Value值

    1.获取Radio值 $('input[name="sex"]:checked ').val(); 2.返填Radio值 $('input[name="sex" ...

  2. VUE-文本-事件-属性指令

    一.Vue文本指令 文本指令: 1.{{ }} 2.v-text:不能解析html语法的文本,会原样输出 3.v-html:能解析html语法的文本 4.v-once:处理的标签的内容只能被解析一次 ...

  3. PHP类知识----clone方法上机实验

    <?php class mycoach { public function __construct($name,$age) { $this->name = $name; $this-> ...

  4. 【Winform-自定义控件】一个自定义的进度条

    0.选择基类 public class MySlider : Control 1.设置控件的Style 在构造函数里添加: public MySlider() { //1.设置控件Style this ...

  5. 【Winform-自定义控件】自定义Tab Control 带关闭符号(X)的标签页

    a form & a tabControl 思路: DrawMode设一定要设为OwnerDrawFixed 事件:Form_Load.tabControl1_DrawItem.tabCont ...

  6. linux下安装虚拟环境

    安装pip $ wget https://bootstrap.pypa.io/get-pip.py $ python get-pip.pypython3 -m pip install --upgrad ...

  7. 慎用javascript自动类型转换

    1.如果把非空对象用在逻辑运算环境中,则对象被转换为true.此时的对象包括所有类型的对象,即使是值为false的包装对象也被转换为true. 2.如果把对象用在数值运算环境中,则对象会被自动转换为数 ...

  8. k8s知识1

    kubernetes到底有多难?看下面的白话: service 网络通信原理service 由k8s外面的服务作为访问端 内部里面其实是pod————————————————————————————— ...

  9. Battle ships HDU - 5093二分匹配

    Battle shipsHDU - 5093 题目大意:n*m的地图,*代表海洋,#代表冰山,o代表浮冰,海洋上可以放置船舰,但是每一行每一列只能有一个船舰(类似象棋的車),除非同行或者同列的船舰中间 ...

  10. Codevs 4829 [DP]数字三角形升级版

    4829 [DP]数字三角形升级版 时间限制: 1 s 空间限制: 16000 KB 题目等级 : 黄金 Gold 题目描述 Description 从数字三角形的顶部(如图,第一行的5表示行数)到底 ...