获取iframe里点击位置相对于页面的位置

470 阅读1分钟

利用Element.getBoundingClientRect()即可

node.addEventListener('click', (e: any) => {
  var iframeRect = iframe.getBoundingClientRect();
  console.log(e.x + iframeRect.left)
  console.log(e.y + iframeRect.top)
})