Pop up PDFs in a new window with jQuery

August 5, 2010 · Chris Peters

My approach to popping up PDF URLs in a new window using jQuery.

I was looking for a good way to pop up all PDF links in a new window and ran across Dennison Uy’s post with code.

Pretty slick and very unobtrusive, and it keeps target="_blank" out of your markup, which is arguably a behavioral and not structural thing anyway. Plus it’s one step closer to killing target="_blank".

My slight modification: being a tad more user friendly

Here’s my version of the code:

view raw pdf_links.js hosted with ❤ by GitHub

And here it is in CoffeeScript:

I basically took what he did and added toolbar=0 to the arguments for window.open().

Why? Jakob Nielsen’s guidelines for opening PDFs in a new window call for removing browser chrome like the Back button. Why? Browser navigation doesn’t fit the paradigm for PDF document navigation. And Nielsen has watched thousands of users fumble around with the web, while most of us have not.

About Chris Peters

With over 20 years of experience, I help plan, execute, and optimize digital experiences.

Leave a comment