PDF File Download and Redirect With One Click Using HTML and JavaScript
PDF File Download and Redirect With One Click Using HTML and JavaScript
- The anchor tag can be used to download files or to redirect to another web page.
- The href attribute creates a hyperlink to file.
- The 'download' attribute specifies that the target(the files specified in the href attribute) will be downloaded when a user clicks on hyperlink.
Here is the simple code to download and redirect the pdf file.
HTML CODE
<a href="filename.pdf" onlclick=" redirectPage('filename.pdf'); " download>
Click here to download
</a>
JAVASCRIPT CODE
<script type = "text/javascript" >
function redirectPage(url)
{
window.open(url);
}
</script>
- Happy Coding
Comments
Post a Comment