S
S
Stom2012-02-27 17:51:23
JavaScript
Stom, 2012-02-27 17:51:23

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

1 answer(s)
K
Keyten, 2012-02-27
@Stom

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();

As an example - http://uadminjs.ucoz.ru/blog/2011-10-15-5 .
(this is a JS framework for CMS uCoz)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question