方法1
$(window).keydown(function(event)
{
if((event.keyCode == 107 && event.ctrlKey == true) || (event.keyCode == 109 && event.ctrlKey == true))
{
event.preventDefault();
}
$(window).bind('mousewheel DOMMouseScroll', function(event)
{
if(event.ctrlKey == true)
{
event.preventDefault();
}
});
});
方法二:
(function () {
/**
* Main stopscrollwheelzoom constructor
*/
let SSWZ = function () {
/**
* Handler for scroll- control must be pressed.
* @param e
*/
this.keyScrollHandler = function (e) {
if (e.ctrlKey) {
e.preventDefault();
return false;
}
}
};
if (window === top) {
let sswz = new SSWZ();
window.addEventListener('wheel', sswz.keyScrollHandler, { passive: false });
}
})();
相关博文
在网页上禁用 ctrl + 鼠标滚动