Window Position
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的更多相关文章
- LeetCode题解-----Sliding Window Maximum
题目描述: Given an array nums, there is a sliding window of size k which is moving from the very left of ...
- [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 ...
- 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 ...
- javascript position兼容性随笔
一.Javascript源码 if (!window.jasen.core.Position) { window.jasen.core.Position = {}; } function Size(w ...
- POJ 2823 Sliding Window + 单调队列
一.概念介绍 1. 双端队列 双端队列是一种线性表,是一种特殊的队列,遵守先进先出的原则.双端队列支持以下4种操作: (1) 从队首删除 (2) 从队尾删除 (3) 从队尾插入 (4) ...
- POJ 2823 Sliding Window 题解
POJ 2823 Sliding Window 题解 Description An array of size n ≤ 106 is given to you. There is a sliding ...
- POJ 2823 Sliding Window
Sliding Window Time Limit: 12000MSMemory Limit: 65536K Case Time Limit: 5000MS Description An array ...
- POJ2823 Sliding Window
Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 53086 Accepted: 15227 Case Time Limi ...
- POJ2823Sliding Window
Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 49919 Accepted: 14391 ...
随机推荐
- kotlin字符串和数字之间的转换和人机交互
继续基础学习~ 字符串和数字之间的转换 那如何转换呢,其实很简单: 编译木有报错,但是运行: 所以这里了解下. 人机交互 看这标题貌似高端的,其实也就是程序可以接受键盘的输入啦,下面开始: 首先提示用 ...
- [Spring Boot] Aspect Intro
Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing another ...
- 【51nod 1038】X^A Mod P
题目描述 X^A mod P = B,其中P为质数.给出P和A B,求< P的所有X. 例如:P = 11,A = 3,B = 5. 3^3 Mod 11 = 5 所有数据中,解的数量不超过Sq ...
- 【agc005d】~K Perm Counting
题目大意 求有多少中1~n的排列,使得\(abs(第i个位置的值-i)!=k\) 解题思路 考虑容斥,\(ans=\sum_{i=0}^{n}(-1)^ig[i](n-i)!(g[i]表示至少有i个位 ...
- 【Python之路】特别篇--Redis
NoSQL(NoSQL = Not Only SQL ),意即“不仅仅是SQL”,泛指非关系型的数据库 随着互联网web2.0网站的兴起,传统的关系数据库在应付web2.0网站,特别是超大规模和高并发 ...
- bat脚本休眠时间技巧
例子: @echo off set /a i=1 :c adb connect 192.168.1.109&ping -n 1 123.45.67.89 -w 10000>nul if ...
- HZOJ 20190722 visit (组合数学+数论)
考试T2,考试时打了个$O(n^3)$dp暴力,思路还是很好想的,但细节也不少,然后滚动数组没清空,而且题又看错了,只得了10pts,真是血的教训. 题解: 其实看数据范围,给出了模数是否为质数,其实 ...
- 【CUDA 基础】2.4 设备信息
title: [CUDA 基础]2.4 设备信息 categories: CUDA Freshman tags: CUDA Device Information toc: true date: 201 ...
- 玩转git和github
1.概念 git---工具,版本控制 github----网站,社交平台,开源项目,远程仓库 2.下载 msysgit是Windows版的Git,从http://msysgit.github.io/下 ...
- 编写批处理使用msbuild编译项目
echo off ::请把此bat脚本放到以下代码路径下 并在环境变量中配置对应版本的vs编译器的值 ::vs2017如:C:\Program Files (x86)\Microsoft Visual ...