简体   繁体   中英

How to auto open downloaded file in new tab in IE 11 or edge like file download work in chrome

I am using windows 10 . I am using msSaveOrOpenBlob of javascript to download the blob return by the Ajax call in IE11. There I don't need any prompt like open, save while downloaded. The PDF file should be opened in new tab exactly like it happen in chrome. But not happening.

Then I checked with tag. Then also it is not able to open without any prompt on click.

My code is like below. click here to download

File download option is enable and there is no option for prompt. PFB the prompt I am getting. 在此处输入图片说明

How a browser handles a PDF file depends on a combination of things.

1.) HTTP Headers

If you want the file to be treated as a file, vs. a "page" to load in the browser ensure you set the content-disposition to attachment and provide a filename with an extension ( with no spaces Firefox gets hung up on this) HTTP Content-Disposition Docs eg

Content-Disposition: attachment; filename="filename.pdf"

2.) New Tab/new window

If you want your content to be loaded in another tab/window, you'll want to set the target attribute of your form/link to _blank .

3.) Browser settings

If the browser has a plugin installed (eg Adobe Acrobat) to handle PDFs, there are configurations in Acrobat to determine if the app opens PDFs separately in the application... or "embedded" in the browser. Note that modern browsers (Chrome/Firefox/etc.) also have their own built in PDF rendering without a need for a plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM