Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.open with headers

Can I control the HTTP headers sent by window.open (cross browser)?

If not, can I somehow window.open a page that then issues my request with custom headers inside its popped-up window?

I need some cunning hacks.

like image 753
Andrew Bullock Avatar asked Dec 01 '10 15:12

Andrew Bullock


People also ask

Can we pass headers in window open?

@sureshvv — No. You cannot control the headers sent there either. If it preserves login status that is because the login method doesn't use custom headers.

How do I create an authentication header in windows open?

Make an HTTP GET request to the resource sending the authentication token in a header, setting its responseType to a binary data type, for example blob or arraybuffer. Download the binary data in a file using the "Save As" dialog from the browser, usually creating a download link for the binary data and clicking it.

How do I open a URL with spaces?

open with a url with spaces: var msg = 'Hello, world! '; var url = 'http://yoursite.com'; var link = 'http://www.twitter.com/share?text=' + msg + '&url=' + url; window. open(link);

What does window open return?

When window. open() returns, the window always contains about:blank . The actual fetching of the URL is deferred and starts after the current script block finishes executing. The window creation and the loading of the referenced resource are done asynchronously.


1 Answers

Can I control the HTTP headers sent by window.open (cross browser)?

No

If not, can I somehow window.open a page that then issues my request with custom headers inside its popped-up window?

  • You can request a URL that triggers a server side program which makes the request with arbitrary headers and then returns the response
  • You can run JavaScript (probably saying goodbye to Progressive Enhancement) that uses XHR to make the request with arbitrary headers (assuming the URL fits within the Same Origin Policy) and then process the result in JS.

I need some cunning hacks...

It might help if you described the problem instead of asking if possible solutions would work.

like image 172
Quentin Avatar answered Sep 20 '22 13:09

Quentin