Get current page http status from javascript

Yes You can

Simply request the same page, i.e. URI, using the XMLHttpRequest. Suppose that your page on /stop.php in stop.php you may do something like:

<script>
function xhrRequest(){            
            console.log(this.status);
            // Do some logic here. 
        }
function getReq(url){
            var oReq = new XMLHttpRequest();
            oReq.addEventListener("load", xhrRequest);
            oReq.open("GET", url);
            oReq.send();
        }
getReq("/stop.php");
</script>

Checkout this DEMO

🕯 Note:

You have to note that, it is a copy of the page not the page itself. I, already, have used this solution on a page in which the server may generate Forbidden HTTP status code when the request is come from unauthorized IP address, so the condition here is very simple and there is no much difference between the original and the copy page that you have simulate its visit.


This is not in any way possible, sorry.