Skip to content

Instantly share code, notes, and snippets.

@elliottkember
Created January 12, 2010 22:28
Show Gist options
  • Save elliottkember/275695 to your computer and use it in GitHub Desktop.
Save elliottkember/275695 to your computer and use it in GitHub Desktop.
$(document).ready(function(){
if($.browser.safari){
height = parseInt($('#wrapper').css('height'));
number = height / 100;
for(i=0;i<number;i++){
$("<a name="+i+"></a>").css('position','absolute').css('top', i*100+'px').appendTo($('body'));
}
}
})
if($.browser.safari){
var key_counter = 0;
$(document).keydown(function(e) {
old_key_counter = key_counter;
if(e.keyCode == 40){
key_counter += 1;
}
if(e.keyCode == 38){
key_counter -= 1;
}
if ( e.keyCode == 32 ){
if( e.shiftKey == 1 ){
key_counter -= 4;
}else{
key_counter += 4;
}
}
if(key_counter < 0){
key_counter = 0;
}
if ((key_counter+6) * 100 >= parseInt($('#wrapper').css('height'))){
key_counter = old_key_counter;
}
document.location.hash = key_counter;
setTimeout(function(){
window.location.hash = "";
}, 0)
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment