P.S. If anyone wants to use this, the code as copied from the URL above doesn’t work because it uses curly quotes. Try this instead:
/*adding target to pdf attachment*/
function add_target() {
?>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function($){
$(".entry-content a[href$='pdf']").attr('target','_blank'); /*you can use other target attribute beside _blank*/
});
</script>
<?php
}
add_action('wp_footer','add_target');