in this page http://api.jquery.com/category/effects/
when you put ‘up'(keyboard) and ‘down’,then put ‘enter’,it will go to the current url,
and when you put ‘backspace’
it will always show the same ‘li’ element you put ‘enter’.
how to set this.
this is my code:
shortcut.add("up",function(e) {
var a=$('#start > div:first-child');
var b=$('#start > div.live')[0];
var c=$('#start > div:last-child');
if(b==a[0]){
b=$(b);
b.removeClass('live');
c.addClass('live');
b=c;
}
else if(b){
b=$(b);
b.removeClass('live');
b.prev().addClass('live');
}
else{
b=$(b);
a.addClass('live')
}
//
var a=$('#start > div.live a')[0];
a.focus();
a.focus(function(){
this.parent().parent().addClass('live');
})
//
var currentHeight = b.outerHeight(), offset = b.prev().offset();
//alert(currentHeight+' '+offset.top)
var _targetScrollTop = Math.round( offset.top - currentHeight - ($(window).height()/3) );
//$('html,body').animate({ scrollTop: _targetScrollTop }, 100);
$('html,body').scrollTop(_targetScrollTop);
//
});
shortcut.add("down",function(e) {
var a=$('#start > div:first-child');
var b=$('#start > div.live')[0];
var c=$('#start > div:last-child');
if(c[0]==b){
b=$(b);
b.removeClass('live');
a.addClass('live');
}
else if(b){
b=$(b);
b.removeClass('live');
b.next().addClass('live');
}else{
a.addClass('live');
}
//
var a=$('#start > div.live a')[0];
a.focus();
a.focus(function(){
this.parent().parent().addClass('live');
})
//
if(!b)return;
var currentHeight = b.outerHeight(), offset = b.next().offset();
//alert(currentHeight+' '+offset.top)
var _targetScrollTop = Math.round( offset.top - currentHeight - ($(window).height()/3) );
//$('html,body').animate({ scrollTop: _targetScrollTop }, 100);
$('html,body').scrollTop(_targetScrollTop);
//
})
}
Javascript doesn’t work across different web page.
You need to pass parameter like #up #down or something like that to the url.
You may interest jQuery’s history plugin
http://plugins.jquery.com/project/history