首页 > 其他 > 详细

获得窗口div坐标及大小(typescript)

时间:2021-04-12 12:42:22      阅读:19      评论:0      收藏:0      [点我收藏+]
  • 获得iframe uiWin的location信息
let a =  window.parent.document.querySelector(‘#uiWin‘).getBoundingClientRect();
  • 获得窗口div坐标及大小(支持浏览器任意情况)
//获得窗口div坐标及大小(支持浏览器任意情况)
VideoPoint(e: MouseEvent) {
    let videoLoaction = this.$refs[‘refVideo‘] as any;
    let h = videoLoaction.offsetHeight;//div 高度
    let w = videoLoaction.offsetWidth;//div 宽度
    let y = videoLoaction.offsetTop;//div左上y坐标
    let x = videoLoaction.offsetLeft; //div左上x坐标  
    let xParam = (e.screenX - e.clientX);
    let yParma = (e.screenY - e.clientY);
    let obj = { x: x + xParam , y: y + yParma, w: w, h: h };
    console.log(JSON.stringify(obj));
    return obj;
}

获得窗口div坐标及大小(typescript)

原文:https://www.cnblogs.com/anjun-xy/p/14646569.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!