javascript - jQuery focus() page scroll length -
javascript - jQuery focus() page scroll length -
i've got code this:
<a href="javascript://" onclick="$('#newmsgtxt').focus();">new message</a> <div style="min-height: 1300px;"></div> <textarea id="newmsgtxt"></textarea> <div style="min-height: 500px;"></div>
and here problem: after click link, in different browsers page scroll different position.
example of textarea
position on screen after click:
chrome: center ff: bottom opera: top
how can create browsers work chrome do?
$('a').click(function(e){ e.preventdefault(); var o = $('#newmsgtxt').focus().offset().top, $w = $(window); $w.scrolltop(o - ($w.height() / 2)); });
http://jsfiddle.net/2bhrw/
javascript jquery css browser cross-browser
Comments
Post a Comment