Answer the question
In order to leave comments, you need to log in
Sending XMLHttpRequest with Referer header changed?
I need to send a request (XMLHttpRequest) from site.ru to site.ru/req with the header Referer: 'site.ru/ref'. I tried the setRequestHeader('Referer', 'site.ru/ref') method of the XMLHttpRequest object, but for security reasons, some headers cannot be changed (Google Chrome browser).
Then the idea came to create an iframe, load site.ru/ref into it, and send a request from this iframe, in theory, in this way, the value of the iframe address will be put in the Referer header.
Tell me how to send a request from an iframe, or if this does not work, an alternative method of replacing the Referer header.
Answer the question
In order to leave comments, you need to log in
Any iframe has a contentWindow property, through which we can accordingly get the xhr of the page. Well, for example:
// ifr - наш ифрейм
var xhr = new ifr.contentWindow.XMLHTTPRequest();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question