How to download PDF files automatically instead of opening in new tab

By default, most downloadable PDF files usually open in a new window or tab. It’s true for the static site or WordPress sites also. This document contains steps on how to make the browser download PDF files automatically, rather than open in a new tab.

We’ll use a simple jQuery solution for it.

    jQuery(document).ready(function($) {
    	$('a[href$=".pdf"]').attr('download', '');


I'm a freelance Wordpress Front-end Developer, work from my home office. Mostly do my freelance work on Upwork. I'm a TOP RATED freelancer with over 11K+ Work Hours. Specialize in HTML5, CSS3, SCSS, JavaScript, jQuery, Ajax, ES6, Bootstrap, PHP, MySQL, Wordpress, Woocommorce and Custom Wordpress Theme and Plugin Development

Leave a Reply

Close Menu