我想在此网站上禁用滚动,直到点击加入邮件列表按钮。这是网站:
http://www.fashionweekny.net/
此外,有PC的人告诉我,根本没有滚动方法。我不再有PC了,我不知道为什么。我似乎无法在S.O.s之前的问题中找到任何解释。滚动按照它应该在我的计算机(mac)上使用鼠标滚轮和触控板滚动的方式工作,但似乎箭头键根本不滚动。它似乎与浏览器的类型无关。
这是与滚动相关的代码... JS:
$('#about-section').click(function (e) {
e.preventDefault();
if ($(this).hasClass('disable_scroll'))
return false;
else
window.location.href = $(this).attr('href');
});
if (disable_scroll == true)
$('#about-section').addClass('disabled')
else
$('#about-section').removeClass('disabled')
$(document).ready(function() {
disable_scroll();
})
document.getElementById("enable").onclick = function() {
enable_scroll();
};
document.getElementById("to-about-section").onclick = function() {
disable_scroll();
};
var keys = [37, 38, 39, 40];
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function keydown(e) {
for (var i = keys.length; i--;) {
if (e.keyCode === keys[i]) {
preventDefault(e);
return;
}
}
}
function wheel(e) {
preventDefault(e);
}
function disable_scroll() {
if (window.addEventListener) {
window.addEventListener('DOMMouseScroll', wheel, keydown, false);
}
window.onmousewheel = document.onmousewheel = wheel;
document.onkeydown = keydown;
}
function enable_scroll() {
if (window.removeEventListener) {
window.removeEventListener('DOMMouseScroll', wheel, keydown, false);
}
window.onmousewheel = document.onmousewheel = document.onkeydown = true;
}