What are the best practices for handling browser navigation buttons in PHP when designing an installation script?

When designing an installation script in PHP, it's important to handle browser navigation buttons properly to prevent users from accidentally navigating away from the installation process. One way to achieve this is by disabling the back and forward buttons in the browser while the installation script is running. This can be done using JavaScript to prevent users from navigating away from the installation page.

<script type="text/javascript">
    history.pushState(null, null, document.URL);
    window.addEventListener('popstate', function () {
        history.pushState(null, null, document.URL);
    });
</script>