2

I have a URL, which points to an image and returns a response with content-disposition: attachment.

This prompts the browser to display a "Save As" prompt to download the image.

Is it possible, using javascript, to open that image in a new tab instead of downloading it?

martixy
  • 784
  • 1
  • 10
  • 26
  • Only if it is not cross-origin to begin with, or CORS-enabled otherwise. (Then you could request the image data via AJAX, and get it to display using a Data URI/Blob URL/Object URL.) – 04FS Feb 06 '19 at 12:53
  • True. Origin is not a issue here however. Can you elaborate? Maybe make it into an answer? – martixy Feb 06 '19 at 12:55
  • If you don't have access to the server's code, you might want to think about placing some kind of proxy that will make the request for you and return it as a regular image (not as attachment) – ChatterOne Feb 06 '19 at 12:59
  • https://stackoverflow.com/questions/27798126/how-to-open-the-newly-created-image-in-a-new-tab has answers using a basic Data URI, as well as a Blob. – 04FS Feb 06 '19 at 13:03

0 Answers0