我有一个可滚动的DIV,里面有一个表。 是否可以在某种类型的onmove()方法中捕获滚动位置,这样我就可以将它放在cookie中,并在页面重新加载时将滚动条恢复到相同的位置。 这是我的JSP代码
<div id="wordListTableDiv" style="overflow: auto;height: 700px; width: 320px; max-width:320px; border:2px solid black; background-color: #FFFFF0; padding: 10px">
<br>
<div>
<br>
<input type="button" value="Show All" onclick="getWordList()" style="float: left;">
<input type="button" value="Hide Ignored and Good" onclick="hideIgnoredAndGoodWords();" style="float: right;">
</div>
<br></br>
<table id="wordListTable" border=1 >
<thead id="wordListTableHead"><tr>
<th width="150">Word</th>
<th width="150">State</th>
</tr></thead>
<tbody><%-- Empty to begin with, filled by JavaScript. --%></tbody>
</table>
</div>
我的JavaScript是
function setScrollPosition()
{
//If the scroll position was set previously then reposition it to the old value.
var scrollPosition = readCookie("scrollPositionCookie");
if( scrollPosition != null )
{
$("#wordListTableDiv").scrollTop( scrollPosition );
}
}
但除非我打开萤火虫并设置一个断点,它从我的cookie设置滚动值,它将始终位于'0'位置。我是否认为这是一个时间问题?
请忽略问题。我发现了导致我的计时问题的JSON调用:(