JonathanOld Posted May 18, 2021 Posted May 18, 2021 Site URL: https://www.robinburgess.com/ On this website, some of the pdfs open in new tabs, while some are being downloaded. This seems inconsistent to me, because I link all pdfs in markdown with <a href="/s/link-to-.pdf" target="_blank">Linktext</a> However, the behavior of the pdfs changes, seemingly randomly. For example, when clicking on "DEMAND FOR ELECTRICITY ON THE GLOBAL ELECTRIFICATION FRONTIER", the pdf opens in a new tab, but for "WHY DO PEOPLE STAY POOR?", it downloads. I'm using Google Chrome, but I want the behavior to be the same across all modern browsers. I have already tried to force this with a site-wide code injection, but it didn't work. <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> $('a[href*="pdf"]').click(function(e) { 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 }); </script>
LindaBee Posted August 31, 2023 Posted August 31, 2023 Did you ever find a solution to this? I'm having the same issue
tuanphan Posted September 3, 2023 Posted September 3, 2023 On 8/31/2023 at 1:42 PM, LindaBee said: Did you ever find a solution to this? I'm having the same issue Can you share link to page where you have problem? We can take a look Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment