调用焦点时,Chrome会重置textarea滚动条(scrollTop)

时间:2010-10-23 03:24:26

标签: google-chrome focus textarea scroll

Chrome(7.0.517.41 beta)(有时会?)在您拨打scrollTop时重置textarea的滚动条(focus)。有谁知道这种行为是故意的,一个已知的错误,还是两者都没有?

这似乎很不直观; Firefox保持不变。一个简单的例子如下:

<?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">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>

0 个答案:

没有答案