Hey Everyone..!
Hope you all doing well.
Many Developers would have came across this small issue while developing a site, where you will get requirements from business that they don't want their PDF to be open in a new window as they takes time if their sizes are more than 10MB, so they will ask you to make the document to get downloaded automatically instead of opening in a new window.
So I've a simple solution for it.
Example:
I've a table with many rows, containing hyperlink data, which opens in a new window on clicking, but i want them to get downloaded automatically
<a href="https://aaaaaaaaaaaaaaaaaaaaaaaa/My Document.pdf" target="_blank">My Document</a>
Solution
<a href="https://aaaaaaaaaaaaaaaaaaaaaaaa/My Document.pdf" download="My Document">My Document</a>
Hope you all doing well.
Many Developers would have came across this small issue while developing a site, where you will get requirements from business that they don't want their PDF to be open in a new window as they takes time if their sizes are more than 10MB, so they will ask you to make the document to get downloaded automatically instead of opening in a new window.
So I've a simple solution for it.
Example:
I've a table with many rows, containing hyperlink data, which opens in a new window on clicking, but i want them to get downloaded automatically
<a href="https://aaaaaaaaaaaaaaaaaaaaaaaa/My Document.pdf" target="_blank">My Document</a>
Solution
There is a HTML5 attribute "download". with which we can easily download all the files
Source Code
<a href="https://aaaaaaaaaaaaaaaaaaaaaaaa/My Document.pdf" download="My Document">My Document</a>
Nice one
ReplyDelete