Reputation: 9804
I have a local file called test.html. The path to this file (relative) is "../slides/test.html".
I would like to :
How can i do these 2 things ?
I tried to get the file with ajax, i get data object containing html code of the file, but i don't know how to do to download and opening this file.
$.ajax({
url: "../slides/test.html",
success: function(data){
alert(data);
}
});
UPDATE
I solve the problem by doing this :
<ul class="buttonsList">
<li><a href="#" id="fullscreenBtn">View in fullScreen</a></button></li>
<li><a href="#" id="downloadBtn" download>Download</a></button></li>
</ul>
// Register click on download button
$("#downloadBtn").off().on('click', function() {
var slideURL = $(".helpActive").attr("data-textTour-url");
$('#downloadBtn').attr({href : slideURL});
});
// Register click on download button
$("#fullscreenBtn").off().on('click', function() {
var slideURL = $(".helpActive").attr("data-textTour-url");
$('#fullscreenBtn').attr({target: '_blank', href : slideURL});
});
Upvotes: 2
Views: 5039
Reputation:
For download
<a href="path-to-file" download>Download</a>
For open in new tab
<a href="path-to-file" target="_blank">Open in new tab</a>
Upvotes: 4