I’m trying to figure out if it’s possible to create a script that will find out the user’s http status code if it’s 200 or 301 for a a script like this for example? Must be a user request status code and not how the server gets it 🙂
<script type="text/javascript"
src="https://google.com"
</script>
Is it possible?
edit: I read and researched more it might be possible with Ajax Requests?
The answer is sadly no.
In a cross-browser, end-user script (ie: one that doesn’t use custom extensions/browser plug-ins), you can’t read through past file requests, for HTTP-response header values.
If you make an AJAX call, you can read response headers for that particular request (not for any others).
So, in theory, if you wanted to know what the server-response was, you could make an AJAX request for the exact-same file as your script request used in its
srcattribute…But not in this case.
In this case, unless your domain is
google.com, your browser is going to prevent you from making that request (as AJAX calls need to happen from the same domain as the page the user is currently on) there are ways around that on newer browsers, but even in those cases, you’d need to owngoogle.comso that your server was set to allow AJAX calls frommysite.com