I found the solution after some testing, so here giving back to the community.
The below row of code only works one time for a reason I don't understand.
Replacing that line of code with the line underneath solved the issue.
var container = document.getElementsByClassName("mx-name-container5")[0];
var container = $(".mx-name-container5");
I found the jQuery selector method using this link:
https://www.w3schools.com/jquery/jquery_ref_selectors.asp
Cheers all!
It may be possible to make the script kick off again using the onpopstate eventhandler:
The onpopstate
property of the WindowEventHandlers
mixin is the EventHandler
for processing popstate
events on the window.
A popstate
event is dispatched to the window each time the active history entry changes between two history entries for the same document. If the activated history entry was created by a call to history.pushState()
, or was affected by a call to history.replaceState()
, the popstate
event's state
property contains a copy of the history entry's state object.
Source: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate
Found via someone who had a similar problem.