js 获取http响应头信息
// 创建一个新的XMLHttpRequest对象
var req = new XMLHttpRequest();
// 注意:使用同步请求可能导致主线程阻塞,不建议在实际生产环境中使用
req.open('GET', document.location, false);
//发送请求
req.send(null);
// 获取所有响应头信息,并将其转换为小写格式
var headers = req.getAllResponseHeaders().toLowerCase();
// 通过alert窗口显示响应头信息
alert(headers);
// 在控制台中打印响应头信息
console.log(headers);
浙公网安备 33010602011771号