跨浏览器获取参数

获取窗口位置:

var leftPos = (typeof window.screenLeft == "number") ? window.screenLeft : window.screenX

var topPos = (typeof window.screenTop == "number") ? window.screenTop: window.screenY

获得页面视口大小:

var pageWidth = window.innerWidth
var pageHeight = window.innerHeight
if(typeof pageWidth != "number") {
  if (document.compatMod == "CSS1Compat") {
    pageWidth = document.documentElement.clientWidth
    pageHeight = document.documentElement.clientHeight
  } else {
    pageWidth = document.body.clientWidth
    pageHeight = document.body.clientHeight
  }
}

 

posted @ 2019-09-12 18:55  寒筱洱  阅读(212)  评论(0编辑  收藏  举报