How to use Javascript to reload requested page from custom 505 error?

568 Views Asked by At

I've created a custom 505 error page for my site (as the default one that shows up is pretty nasty on the eyes). Everything is as it should be but I'm unsure about my usage of JS, I am trying to link the 'Retry' button in this image:

Image 001

to a javascript/jQuery action that will reload the page that was initially requested.

i.e If the user requested example.com/thispage and they were shown the custom '500 Internal Server Error' page, when they click on 'Retry' the reload request would be for the example.com/thispage page.

The javascript I'm using is:

<a href="javascript:window.location.href=window.location.href"><img src="IMAGE SOURCE HERE"></a>

In test mode (i.e loaded from my local documents folder) this just refreshes the custom error page.

So I guess I have 2 questions:

1) Will this reload the requested URL or the custom 505 error file;

2) If it will reload the file how can I use JS to reload the initial page request?

Note: I have included jQuery:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

in the head of the document.

1

There are 1 best solutions below

2
Lorenzo Catalano On

you can try

window.location.href=document.referrer

but i'm ot sure it will work in every situation