zoukankan      html  css  js  c++  java
  • 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:

    1 var leftPos = (typeof window.screenLeft == "number")? window.screenLeft : window.screenX;
    2 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.

      

  • 相关阅读:
    博客园设置自定义壁纸 模板
    html常用标签及属性,常用英语单词
    解释器安装与环境变量的添加
    计算机基础知识
    python 标准库大全
    进程的状态转换详解
    python 合集set,交集,并集,差集,对称差集别搞混
    vue组件,可以通过npm引用的组件
    use vue vuex vue-router, not use webpack
    Webpack+Vue如何导入Jquery和Jquery的第三方插件
  • 原文地址:https://www.cnblogs.com/linxd/p/4515026.html
Copyright © 2011-2022 走看看