@if(session()->has('errors'))
{{ session('errors') }}
@php
request()->session()->forget('errors')
@endphp
<script>
window.onload = function() { // code to display alert }
</script>
@endif
The message keep being shown when using browser navigation. The javascript code is inside @if @endif, so this should not be the reason.