I'm wondering is it possible to automatically add target=_blank
to any PDF link I have on my website, so that it will convert
<a href="pdf1.pdf">link text</a>
<a href="pdf2.pdf">link text</a>
to
<a href="Pdf1.pdf" target="_blank">link text</a>
<a href="Pdf2.pdf" target="_blank">link text</a>
as this site has a lot of PDFs, and it would be easier to do this automatically rather than have to set them all one-by-one.
I have tried the Javascript solution:
$(".newWindow a[href$='pdf']").attr('target','_blank');
But am wondering is there a way to do this automatically in PHP, perhaps by adding something to Wordpress's functions file?