【发布时间】:2023-03-29 15:51:01
【问题描述】:
我通过异步回发将多行文本框用作聊天窗口。我能够保持滚动位置,但是当用户阅读聊天消息时,文本框会自动滚动到最底部。我能够保持用户所在的位置或使其自动向下滚动。但是,我想两者都做。
这是我的代码:
var prm = Sys.WebForms.PageRequestManager.prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get('txtChatBox').scrollLeft;
yPos = $get('txtChatBox').scrollTop;
zpos =$get('txtChatBox').scrollHeight;
}
function EndRequestHandler(sender, args) {
$get('txtChatBox').scrollLeft = xPos + 1;
$get('txtChatBox').scrollTop = yPos + 1;
$get('txtChatBox').scrollTop =zpos+1;
}
谁能帮帮我?
提前致谢
【问题讨论】:
-
您应该包含您正在使用的代码,并具体说明哪个部分有问题。
-
删除,使其成为问题的一部分并格式化。
标签: javascript asp.net ajax c#-4.0