I'm currently working on a mp3 player website for a local server.
(我目前正在本地服务器的mp3播放器网站上工作。)
It includes a "player" and a list of songs underneath.(它包括一个“播放器”和下面的歌曲列表。)
The issue is when redirecting to another song (either via clicking or javascript redirect), it scrolls to the top of the page.
(问题是当重定向到另一首歌曲时(通过单击或javascript重定向),它会滚动到页面顶部。)
It's quite annoying when I'm far down the list and clicks on a song.(当我不在列表中并单击一首歌曲时,这很烦人。)
It keeps the position when refreshing the page, but not with redirect.
(刷新页面时,它保持位置,但不带重定向。)
The url looks like this:
(网址看起来像这样:)
http://192.168.1.130/music/listen.php?id=SongName
The only thing that changes during a redirect is the song name for the id.
(重定向期间唯一发生变化的是ID的歌曲名称。)
For the redirect itself, it's either a click or JavaScript that does the action.
(对于重定向本身,是单击或执行操作的JavaScript。)
HTML:(HTML:)
<tr>
<td><a href="/music/listen.php?id=AnotherSong">AnotherSong</a></td>
<td>11.04.2019 15:52</td>
</tr>
JavaScript(的JavaScript)
window.location.href = "/music/listen.php?id=AnotherSong";
Are there any JavaScript / HTML features that keeps the scrolling position?
(是否有任何JavaScript / HTML功能可保持滚动位置?)
Or would I maybe need to store the scrolling position somewhere and set the position again after the redirect has been done?(还是需要将滚动位置存储在某个位置,并在重定向完成后再次设置该位置?)
ask by Typewar translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…