question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remember view position after refreshing the page

See original GitHub issue

Currently the view position is saved by a hash based on the file contents. When the page reloads, we should also take the last position into account, because it matches the normal behavior of browsers. Usually, when you reload a web page, the scroll offset is restored (even if the content of the page changed).

The motivation for this change comes from experiencing the following broken workflow:

  1. Generate a local PDF file (file://....pdf).
  2. Open PDF with PDF.js and scroll to some chapter in the PDF file.
  3. Edit PDF file.
  4. Refresh the PDF.js viewer (e.g. with F5).
  5. Expected result: Retain the scroll position.
    Actual result: Page 1 is shown in the viewport.

Technical notes:

  • performance.navigation.type can be used to detect page reload versus navigations.
  • history.state is preserved when a page reloads.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:34 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Rob--Wcommented, Jul 27, 2018

@ankitverma2211 If possible, tests would be great. However, we don’t have automated tests for this kind of features, so if the patch looks reasonable and passes a manual test, then we would accept it too.

0reactions
allefeldcommented, Nov 26, 2019

I submitted a similar issue #11359 with respect to *latex-generated pdf. It is actually not correct that this uses a “hash based on the file contents” @Rob--W. Rather, it is an ID embedded in the PDF upon creation, and how that ID is generated depends on the generating application, for *latex it is a hash based on the combination of the current time and the pathname of the tex-file. See my last comment there for a solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refresh Page and Keep Scroll Position - javascript
//code to refresh the page var page_y = $( document ). ... To fix this issue, I am removing the scroll position after...
Read more >
How to keep the displayed position after page refreshment?
In an .aspx page, I use <meta http-equiv="refresh" content="10;"/> to refresh the page in order to update data. After each refreshment, the browser...
Read more >
005 – Restore screen position after refresh - YouTube
Learn how to restore your scroll position, when using Oracle Application Express, after a Dynamic Action refreshes a report.
Read more >
Video: 005 – Restore screen position after refresh
Save the scroll position of the page before you open the modal page. Restore the scroll position after the refresh. Here are the...
Read more >
Save last browsing location when page is refreshed?
I'm working on creating a website and need to refresh it several times to ... previously viewing after refreshing at the middle of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found