Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript图像-响应中的访问头_Javascript_Http_Dom_Http Headers - Fatal编程技术网

Javascript图像-响应中的访问头

Javascript图像-响应中的访问头,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'; 服务器的响应与任何其他响应一样包含头。 我的问题是:一旦服务器发送响应,是否有办法在

更改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';
服务器的响应与任何其他响应一样包含头。
我的问题是:一旦服务器发送响应,是否有办法在映像对象的onready、onload或onreadystatechange事件中访问此标题?

没有。只有您自己使用自己的ajax调用下载图像时,标题才可用。当浏览器通过
.src
属性自动进行下载时,不会使图像标题可用

您可能还需要记住,浏览器喜欢在浏览器缓存中缓存图像,从那里加载图像时,它们也不会有标题