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', '');

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *