I’m using this code for my links open blank page:
$("a[href^='http:']:not([href*='" + window.location.host + "'][target='_blank'])").live('click', function(){
$(this).attr('target','_blank');
});
This codes work but i want only pdf files open blank page. How can i do this?
This can be executed immediately at DOMReady (or at any point that a link is added), rather than at the time of an actual click:
Note that this looks for anchors where the
hrefends with.pdf. Therefore, this won’t matchhref="/test/my-document.pdf#some-hash", but then again, there’s no way you’re going to know from just looking at your link what the content type will be of the response that the server is going to send to you if you follow it. So this is probably about as good as it gets.