Use the download attribute.
var link = document.createElement('a');
link.href = url;
link.download = 'file.pdf';
link.dispatchEvent(new MouseEvent('click'));
More Related Contents:
- How to build PDF file from binary string returned from a web-service using javascript
- Download and open PDF file using Ajax
- Download pdf file using jquery ajax
- pdf file upload ajax html
- Save a pre element as PDF with CSS
- How to display a pdf in a modal window? [closed]
- Injected li items are not formatted with CSS style [closed]
- HTML: how refresh information in [closed]
- Add a property to a JavaScript object using a variable as the name?
- How do I set/unset a cookie with jQuery?
- Disabling and enabling a html input button
- What is the difference between $(window).load and $(document).ready?
- Is it possible to use Ajax to do file upload?
- In Javascript/jQuery what does (e) mean?
- TypeError: Cannot read property ‘setState’ of undefined
- Way to know if user clicked Cancel on a Javascript onbeforeunload Dialog?
- Combine multiple JavaScript files into one JS file [closed]
- Page redirect with successful Ajax request
- jQuery: how to scroll to certain anchor/div on page load?
- JS Events: hooking on value change event on text inputs
- Using jQuery to search a string of HTML
- “This site appears to use a scroll-linked positioning effect. This may not work well with asynchronous panning”
- Pie chart with jQuery
- How to store a global value (not necessarily a global variable) in jQuery?
- Detect Android phone via Javascript / jQuery
- Remove URL parameters without refreshing page
- How to get MIME-TYPE from Base 64 String?
- Html duplicated ID
- .js.erb VS .js
- Javascript Date() give wrong date off by one hour