I want to force a file to be downloaded and I'm trying both ways.
downloading on the same page:
var docLocation = window.location.href + 'docs/apresentacao.pdf';
var iframe = $('<iframe src="' + docLocation + '" class="hidden"></iframe>');
$('body').append(iframe);
* this way the browser tries to interpret the file and returns the message:
Resource interpreted as Document but transferred with MIME type application / pdf
I saw somewhere saying to convert the MIME type to application/octet-stream
with a back-end language and this would force the download.
downloading in a new window:
window.open(docLocation, '_blank');
The problem with this method is that it opens the file in a new (pop-up) window, and because browsers block pop-ups by default, the user would have to allow loading of that window which would eventually cause some users did not see.