Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
166
rated 0 times [  171] [ 5]  / answers: 1 / hits: 38826  / 10 Years ago, tue, november 18, 2014, 12:00:00

Let's say I have a code like this:



<img src='images/whatever.jpj' width='' height=''/>


How to configure custom headers for this request?



Will appreciate any help.


More From » html

 Answers
10

You cannot change the browser's HTTP request for resources loaded by the <img> tag. Whatever you are trying to do, you will need to find an alternative approach.



For example, you could proxy the request through your own server and modify the headers there. Or you could parametrise the URL of the resource with a query string.



As Alex points out, you may also be able to use an XmlHTTPRequest object to load the image data and use the setRequestHeader function, though I suspect you are limited in what headers you can set (I doubt you can spoof the referrer or user agent for example, though I haven't tested this).


[#68775] Friday, November 14, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
analiseg

Total Points: 460
Total Questions: 96
Total Answers: 90

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
;