Content automatically scrolled down on 2012 platform
Focus location depending on the anchor position which can result in scrolling the content.
When an anchor is created by innerHTML with addition of text:
- Webkit 2012
- focus depends on <a> location.
- Maple 2010-2011
- focus is set right next to the text.
Solution
Create the <a> tag in the place when you want to move exactly. If there are large portions of text loaded, locate <a> before the text.
Source Files
Note
The files needed for the sample application are here.
Bad example
var desc = "The quick brown fox jumps over the lazy dog.";
var anch = "<a id='ib' href='javascript:void(0);'> </a>";
document.getElementById("ia").innerHTML = desc + anch;
document.getElementById("ib").focus();
<div id="ia">
Good example
var desc = "The quick brown fox jumps over the lazy dog.";
var anch = "<a id='ib' href='javascript:void(0);'> </a>";
document.getElementById("ia").innerHTML = anch + desc;
document.getElementById("ib").focus();
<div id="ia">