Skip to content

Strange error when pressing backspace (previous page) #601

Answered by triskweline
spapas asked this question in Q&A
Discussion options

You must be logged in to vote

My guess is that your <script> elements live inside the <body>. Going back replaces the <body> by default. This causes your scripts to be run a second time.

Use one of the following methods to address this:

  • Move your scripts into the <head> and use <script defer>
  • Set up.history.config.restoreTargets to a selector that does not include your scripts, e.g. a <main> element.
  • Disable execution of scripts within updated fragments, using up.fragment.config.runScripts = false

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by spapas
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants