Try this:
$.fn.focusWithoutScrolling = function(){
var x = window.scrollX, y = window.scrollY;
this.focus();
window.scrollTo(x, y);
return this; //chainability
};
and then
$('#link').focusWithoutScrolling();
Edit:
It’s been reported that this doesn’t work in IE10. The probable solution would be to use:
var x = $(document).scrollLeft(), y = $(document).scrollTop();
but I haven’t tested it.