如何在不使用 JS 发出新请求的情况下读取当前标头?

2022-01-17 00:00:00 http-headers javascript

可能重复:
在 Javascript 中访问 HTTP 标头?

我知道用 javascript 读取当前标题的唯一方法是:

The only way what i know to read with javascript the current headers is:

var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();

但我不想发出新请求,我想读取当前标头.

But i don't want make a new request, i want read the current headers.

这可能吗?谢谢!

推荐答案

不发送ajax请求,无法通过Javascript访问页眉.

It's not possible to access page headers via Javascript, without sending ajax request.

相关文章