Opening PDFs in a new window

by Matt Sital-Singh on Aug 05, 2009
Filed Under:

A request we often get from customers is to make all links to PDF files in their Plone site open in a new window. This prevents the confusing situation where some browsers load the PDF inside the browser window, causing the user to accidently quit the browser when trying to close the PDF file.

As long as the PDF files in question have the '.pdf' extension, then this snippet of jquery usually does the trick:

jQuery("#content a[ @href $= '.pdf']").attr('target', '_blank');