jsp文件中body里有一个div,这个div和body的高度不一样,我用js动态的向div中添加内容,每次添加内容是会判断 如果这个div中的滚动条在底部,添加内容成功后,滚动条会滚动到底部,如果滚动条不在底部,添加内容成功后,滚动条的位置不变。
if(document.getElementById('resShow').scrollTop + document.getElementById('resShow').Height() == document.getElementById('resShow').scrollHeight){
createContext(text);//动态的向div中添加一行或多行内容
document.getElementById('resShow').scrollTop=document.getElementById('resShow').scrollHeight;
}
else
createContext(text);
这个代码没有生效,请大神讲解!