views:

13

answers:

0

Chrome (7.0.517.41 beta) (sometimes?) resets a textarea's scroll bar (scrollTop) when you call focus. Does anyone know if this behavior is deliberate, a known bug, or neither?

It seems quite unintuitive; Firefox keeps it the same. A simple example is below:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<title></title>
</head>
<body>
<textarea id="text" rows="35" cols="160">
Long filler text here
</textarea>
<script type="text/javascript">
var t = document.getElementById("text");
t.blur();
t.scrollTop = 500;
console.log("Before focus: " + t.scrollTop);
t.focus();
console.log("After focus: " + t.scrollTop);
</script>
</body>
</html>