$(document).keydown(function(event){
scrollHeight = jQuery('html').scrollTop();
if(event.keyCode == '33')
{
if(scrollHeight >= 0.0*docHeight && scrollHeight < 0.5*docHeight)
{
$(document).scrollTop(0.0*docHeight);
}
else if(scrollHeight >= 0.5*docHeight && scrollHeight <= 1*docHeight)
{
$(document).scrollTop(docHeight);
}
}
if(event.keyCode == '34')
{
if(scrollHeight < 0.45*docHeight)
{
$(document).scrollTop(0.0*docHeight);
}
else if(scrollHeight >= 0.45*docHeight && scrollHeight <= 1*docHeight)
{
$(document).scrollTop(docHeight);
}
}
});
我有3个分区,如果滚动朝向第3分区,则在按下分页键时,应显示第3分区。
此代码在firefox中运行,但不在chrome中。