
You can change it to a different URL of your choice.

The div element is just a wrapper for the rest of the elements.

The client decides what to do according to the content-disposition and content-type headers, end of story. A simple anchor that points to a file with a known content-type header. This is the most common type of file link. This isn’t an exhaustive list of possible combinations, but it does demonstrate what options are available to combine. Methods of downloadingīelow are some possible methods of file downloading and how they work. This can cause some un-expected problems in the way that files are handled. I’ve hit a scenario where I’d forgotten to set the content-type header on an Azure blob item, which means it defaulted to application/octet-stream. For example, a type of application/pdf will most often be opened in a new browser window in Chrome. Clients will handle different content types in certain ways.

I’d recommend setting them both (if you can) on all resources. It’s important to be aware of 2 headers that affect how clients deal with files on web pages. If you just want some code that ‘almost’ forces a file download, skip to the end. If you are interested in some background on file opening or downloads, read on.

You can’t make it to anything, but you can very strongly suggest. But you can get damn close.Īs with a lot of things on the web, the download or open behaviour of a file is up to the client. To cut a very long story short, you can’t. If you’re reading this, you are probably trying to figure out how to force a file download using JavaScript.
