Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndrew Hinkson
Full Stack JavaScript Techdegree Graduate 25,822 PointsEverything works except the download portion.
const $odd = $('a:odd'); const $secureLinks = $('a[href^="https://"]'); const $pdfs = $('a[href$=".pdf"]'); const $pdfCheckbox = $('<label><input type="checkbox">Allow PDF downloads</label>');
$secureLinks.attr('target', '_blank'); $pdfs.attr('download', true);
$secureLinks.addClass('secure'); $pdfs.addClass('pdf');
$pdfs.on('click', function(event) { if ($(':checked').length === 0) { event.preventDefault(); alert('Please check box to allow pdf downloads!'); } });
$('#links').append($pdfCheckbox)
When I click the pdf link it just takes me to another tab. Ive looked everything over and can't seem to get it to download the pdf.
Any help would be appreciated.
2 Answers
Schaffer Robichaux
21,729 PointsHey Andrew,
I was experiencing the same issue. I believe it is due to a change in browser policy- in my case Chrome V67.0. It's likely that the policy change took place after the video was created.
Hope that helps
Victoria Aoka
7,652 PointsHello, This can be resolved by changing your browser's settings to allow automatic pdf downloads. This link here can help with the settings depending on the browser you are using. Once you change the browser settings, the app should be able to work as expected.
Andrew Hinkson
Full Stack JavaScript Techdegree Graduate 25,822 PointsAndrew Hinkson
Full Stack JavaScript Techdegree Graduate 25,822 PointsYea I figured it had something to do with my browser. I just wanted to make sure that at least the code was right. I will have to do more research on how to get this to work in updated browser. Thanks!
Courtney Pure
8,983 PointsCourtney Pure
8,983 PointsThanks Schaffer Robichaux I am experiencing this as well. It makes sense.