Diane2
Diane2

Reputation: 160

window.open Data URI

I have a base64 string and would like to pass it into window.open()

window.open("data:application/pdf;base64, " + escape(base64String));

My problem is that I don't want to have to specify

application/pdf

because it can be an image, pdf, excel file and anything else.

How can I do this?

Upvotes: 1

Views: 8108

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074545

You'll need to know what MIME type to put there, I'm afraid, ideally by getting that information from the same source you're getting the data string from. If you don't include one, it defaults to text/plain;charset=US-ASCII, which probably isn't what you want.

Upvotes: 1

Related Questions