Javascript图像-响应中的访问头
更改Javascript图像对象的.src属性时,会将请求发送到指定的URLJavascript图像-响应中的访问头,javascript,http,dom,http-headers,Javascript,Http,Dom,Http Headers,更改Javascript图像对象的.src属性时,会将请求发送到指定的URL // new image object var imgObject = new Image(); // assign the path to the image to the src property imgObject.src = 'http://example.com/' + 'image/image.jpg'; 服务器的响应与任何其他响应一样包含头。 我的问题是:一旦服务器发送响应,是否有办法在
// new image object
var imgObject = new Image();
// assign the path to the image to the src property
imgObject.src = 'http://example.com/' + 'image/image.jpg';
服务器的响应与任何其他响应一样包含头。
我的问题是:一旦服务器发送响应,是否有办法在映像对象的onready、onload或onreadystatechange事件中访问此标题?没有。只有您自己使用自己的ajax调用下载图像时,标题才可用。当浏览器通过
.src
属性自动进行下载时,不会使图像标题可用
您可能还需要记住,浏览器喜欢在浏览器缓存中缓存图像,从那里加载图像时,它们也不会有标题