Getting Header Information Inside Javascript
Is there a way to get the HTTP header information of the current page in JavaScript? I am trying to get the header information of a page like referer and other headers. How can I g
Solution 1:
Use document.referrer for referrer. Use Ajax to get the rest.
functiongetHeadersAjax(url) {
var r = GetXmlHttpObject();
r.open('HEAD', url, false);
r.send(null);
return {
status: r.status,
statusText: r.statusText,
referrer: document.referrer,
rawheaders: r.getAllResponseHeaders()
};
}
Post a Comment for "Getting Header Information Inside Javascript"