Does anyone know of a working script that will make all pdf links in a site open to a new tab? After adding a lot of pdf links to a site in development, the owners changed their minds and now want them to open in a new tab instead of the same window.
I'm hoping for a script to do it rather than having to comb through the entire site and edit all the links. I tried this, but it doesn't work - no errors showing from it, just isn't making them open in a new tab as expected:
e.preventDefault(); // stop the existing link from firing
var documentUrl = $(this).attr("href"); // get the url of the pdf
window.open(documentUrl, '_blank'); // open the pdf in a new window/tab