【转】在 iframe 上无法捕获 mousemove

转:https://blog.csdn.net/DongFuPanda/article/details/109533365

在父级给 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/guxingzhe/p/15036637.html