If you want to execute some javascript once the page is fully loaded, you can set up a listener for the 'DOMContentLoaded' event on the document. This will ensure that your script runs not only when the page initially loads but also when navigating back and forth. How you choose to use this javascript to achieve the desired behavior is entirely up to you -- many people opt for utilizing "#uglyhashes".
Here's an example code snippet tailored for Mozilla browsers (and taking into account the updated event name):
document.addEventListener("DOMContentLoaded", function() {
// Your custom script goes here
}, false);