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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -