Can I change the page's HTML status code on the client side?
11,052
Solution 1
It is impossible to set the HTTP Response code using client side programming.
Solution 2
You can redirect the page to a non existent one in JavaScript. I have no idea why you would want to do this, but hey ho:
<script type="text/javascript">
<!--
window.location = "zomgomgthispagedoesntexistlololol.html"
//-->
</script>
But David is right, there is no way to set THAT pages status as it is a client side script.
Author by
Admin
Updated on June 20, 2022Comments
-
Admin almost 2 years
I have a static HTML web page and I want to set its status code to
404
"Not found".But, I want to do this using javascript or jQuery, not any server side language.
How can I do this on the client? With javascript or maybe a
<meta>
tag?