Search code examples
javascriptpdfextjsextjs4

Open pdf in new tab (FireFox and IE 8) using EXTJS, JAVASCRIPT


I'm using EXTJS, i have a link, which is used to open a PDF file. The problem is that the pdf is not opened in the navigator, but it's downloaded ! The code i'm using is the following (which i found in stack ! )

var win = window.open(url, '_blank');

win.focus();

what i'm messing ?


Solution

  • Browser decides whether to open the file or show it inline (in the new tab) depending on received HTTP headers.

    To download, server sends this header:

    Content-Disposition: Attachment; filename="somefile.pdf"
    

    To show inline, server sends this header:

    Content-Disposition: Inline