How to determine the page headers sent using javascript? Tell me the functions, please.

  • What do you mean by "page headers sent" ?? - timka_s
  • For example, 404 error - nick777
  • This is a header sent by the server TOGETHER with a page - timka_s 6:02
  • I understand that this information is already sent to the page and displayed in the title and in the content itself, but I just need to “get” it using javascript. - nick777

2 answers 2

There is a nice extension for Firefox - livehttpheaders.mozdev.org Allows you to view all the headers, and in general all requests. Convenient setting, extremely clear interface. In JavaScript, this, I believe, is inexpedient and impossible.

alt text

There is, however, a way to find out by means of an AJAX request about the existence of a page. That is a 404 error.

(function(link){ var ajax = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Msxml2.XMLHTTP'); ajax.open('get', link, 1); ajax.onreadystatechange = function () { if (ajax.readyState == 4) alert(ajax.status); }; ajax.send(null); })('/404error'); 

Such requests are limited to the limits of the domain name. Where '/ 404error' is the link. If it is not on the site, it will give 404 - the error number.

    In short - no way. But you can do something like that. Study