1

I've been using a button to prompt the download of a .doc file by doing this :

<button type="btn02" class="btn02 btn-default centered" onclick="location.href='http://www.website.com/document/registration_form.docx'">Download Now!</button></h4>

CSS

.btn02 {
background-color: #FFF;
outline-color: #000;
display: inline-block;
margin-left:20px;
}

When I replace the .doc file on the server with a PDF (and adjust the code href to reflect that :

onclick="location.href='http://www.website.com/document/registration_form.pdf'")

... It only opens the PDF in the browser Window instead of prompting it to be downloaded by the viewer... Why does the document format change this?

Is there a way I can make the browser prompt a download for the PDF?

SaintPaddy
  • 37
  • 5
  • take a look https://stackoverflow.com/a/28946907/7141562 – admlz635 Apr 29 '19 at 20:43
  • @AndresMartínez I appreciate that link, that's a lot more Javascript than I'm used to, I was hoping there would be a more inline sort of solution... Adding 'download' doesn't seem to do anything inline. – SaintPaddy Apr 29 '19 at 20:51

1 Answers1

-1

you can use it

<a class="btn02 btn-default centered" onclick="='http://www.website.com/document/registration_form.docx'">Download Now!</a>
Mojtaba
  • 173
  • 7
  • Thank you @motjaba this did not work. It broke the button form and would not prompt a download.. I've since clarified my question and added the CSS. Thank you for the help! – SaintPaddy Apr 29 '19 at 20:28