0

I have a window.open command like this:

window.open("http://MyServer/MyPage");

And I know that I can set accepts of a request, using something like this:

var client = new XMLHttpRequest();
client.open("GET", "http://MyServer/MyPage");
client.setRequestHeader("Accept", "ContentTypeName");
client.send();

Now I need to combine this two things. But I don't know how. So...

How can I set accepts in HTTP header to a call executed by a window.open command?

UPDATED
Here is a very similar question to that: window.open with headers.
And is already answered.

But as the answer suggests I write in my new window, will be not possible if my content type is a binary like:

  • application/pdf
  • application/vnd.ms-excel
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

That for my needs these types will be present. So anyone know how I can do it?

7
  • What you COULD do is to document.write the result of an AJAX call (with request headers set) to the new window Commented Mar 8, 2015 at 16:21
  • Because my content type in many cases is excel or pdf and I can't write this. Commented Mar 8, 2015 at 16:24
  • Why not request /?format=pdf or /pdf/... and have the server generate the content type? Commented Mar 8, 2015 at 16:25
  • Yeah it's possible, but just for curiosity, I want to know if it's possible using accepts parameter. Commented Mar 8, 2015 at 16:30
  • The computer says no... MDN MSDN Commented Mar 8, 2015 at 16:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.