43349

Which file types can be viewed in browser

Question:

I just want to know which file types (like .png, .pdf, .txt) can be viewed in browser (like Chrome, Firefox). Because sometimes when i click on file link, instead of displaying in browser it download automatically. Why this happens ? Below is my code. Any help will be appreciated.

<script> function openPDF(url){ var w=window.open(url, '_blank'); w.focus(); } </script> <a href="burger1.jpg" target='_blank'>link</a> <div onclick="openPDF('1.pdf');">PDF 1</div>

Answer1:

In normal cases, following files can be viewed in browser.

.PNG .JPEG .PDF .doc etc ...

and following files will always be download.

.zip .exe etc ...

But in special cases, it depends on user browser settings and preference. You can get further details from <a href="https://apemobile.zendesk.com/hc/en-us/articles/115001569212-PDF-files-are-downloading-instead-of-displaying-in-web-browser-or-opening-in-a-new-tab" rel="nofollow">this</a> link.

Answer2:

There are two aspects to this issue.

<ol><li>

There are addons you can add on to the browsers to allow viewing virtually anything in the browser window. In the case of PDF, for instance Firefox can't show those by default, but you can install an addon. Or, there are standalone PDF viewers that also come with such an add-on which you can activate if desired.

</li> <li>

And when you've done that, as noticed in the comments, if the resource is marked as download, the browser will download it instead of trying to open it, no matter the file type.<br /> Ditto if it has a http header of Content-Disposition: attachment.<br /> So don't use that.

</li> </ol>

Recommend

  • jquery/javascript post to new window when pressing a preview button
  • Getting Javascript Errors From Another Window
  • How to make image control button for each image inside the div using css and js?
  • Directory structure and labeling in Caffe
  • Convert base64 image to a file in Node Js
  • Python Pillow: Make gradient for transparency
  • Problems using HOGDescriptor
  • Different SSL-certificates for different parts of site
  • How can I stop .htaccess redirecting a subdomain to the main site?
  • Httpclient multipart/form-data post image and json same time
  • jQuery random blockquote
  • Intent Image Capture data==null
  • C# Remove URL from String
  • PHP Copy function not working
  • How to set download location via chrome api
  • PHP file_exists() anomaly
  • IE11 textarea loses focus if another textarea is disabled
  • IOS > Open URL in Safari with POST
  • MVVM: Image Bind Source from FileOpenPicker
  • Outlines on links in IE9 remains when focus is changed
  • How to getText() from the input field of an angularjs Application
  • Simulate click Geckofx vb,net
  • Textfile Structure (tables)
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Jquery UI tool tip close icon
  • Syntax for setting draggablecursor property in google maps api
  • Disabling Alt-F4 on a Win Forms NotifyIcon
  • HTML download movie download link
  • Resize panoramic image to fixed size
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Circular dependency while pushing http interceptor
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Change div Background jquery
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection