top

Content automatically scrolled down on 2012 platform

Published 2014-10-28 | (Compatible with SDK 3.5,4.5,5.0,5.1 and 2012,2013,2014 models)

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);'>&nbsp;</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);'>&nbsp;</a>";
document.getElementById("ia").innerHTML = anch + desc;
document.getElementById("ib").focus();
<div id="ia">