Reputation: 3652
I am using fancybox for form popup and my client does not want to background should be scroll
Firefox is still allow user to scroll background via arrow keys.
Now I blocked the user to press arrow key till popup for complete document, but it will stop the same keydown in my form also.
is these any option for user to block event for all document except form ?
Upvotes: 0
Views: 379
Reputation: 73916
To enable keydown for full document:
$(document).keydown(function(event) {
var charCode = event.which;
alert('Handler for .keydown() called - ' + charCode );
});
And to disable keydown for one div:
$('#target').keydown(function(event) {
event.preventDefault()
});
where target
is the ID of the specific div.
Upvotes: 1
Reputation: 7055
try this-
$(document).keydown(function(event){
if ($(event.target).is('.theForm'))
event.stopPropogation();
else
// block scrolling
});
Upvotes: 4