'I am trying to redirect the page after 5 minutes using javascript

I am trying to redirect page after 5 minutes using JavaScript but my code is not working please help me thanks.

Javascript

 <script type="text/javascript">
            let my_url = "{{route('non-member-booking')}}";
          
            setTimeout(function() {
                    window.location.replace(my_url);
            }, 300000);
    
    </script>


Solution 1:[1]

You can use the following code and it will run with no problems.

setTimeout(function() {
    window.location.href = 'https://google.com/';
}, 300000);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Liam