以下代码的目的是当用户按住 SHIFT 键时,一些文本将指示他们正在按下它。它在 Firefox 中运行良好,但 IE 不承认它。
window.onmousemove = function(e) {
e = e || window.event;
var copyLabel = document.getElementById("<%= lblCopyEnabled.ClientID %>");
if (e.shiftKey) {
copyLabel.style.display = "inline";
ob_copyOnNodeDrop = true;
}
else {
copyLabel.style.display = "none";
ob_copyOnNodeDrop = false;
}
}
不胜感激。
最佳答案
尽管 MSDN 文档怎么说,onmousemove
在应用于 window
对象时不起作用。如果您将它应用于 document
对象,它应该适用于所有浏览器:
document.onmousemove = function(e) {
e = e || window.event;
var copyLabel = document.getElementById("<%= lblCopyEnabled.ClientID %>");
if (e.shiftKey) {
copyLabel.style.display = "inline";
ob_copyOnNodeDrop = true;
}
else {
copyLabel.style.display = "none";
ob_copyOnNodeDrop = false;
}
}
关于javascript - IE 和 Firefox 中的 window.onmousemove,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4257936/