在 iframe 上无法捕获 mousemove

时间:2021-09-11 21:18:08   收藏:0   阅读:19

在父级给 document 添加 mousemove 时间,实现一个拖拽功能。当拖到 iframe 上方时,发现变得卡顿

发现是 iframe 搞的鬼。解决方法也很简单,在 mousedown 和 mouseup 给 iframe 添加个样式

function onMouseDown() {
	document.querySelector(‘iframe‘).style[‘pointer-events‘] = ‘none‘
	// ...
}

function onMouseUp() {
	document.querySelector(‘iframe‘).style[‘pointer-events‘] = ‘auto‘
	// ...
}

  

原文:https://www.cnblogs.com/7c89/p/15253420.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!