I have a quick question, I have my javaScript code setup where it downloads any ".pdf" files that I have on my JavaScript table. How do I make it where it doesn't download the file, but instead opens it up in a new tab?
Here is the code:
JavaScript file: o365FileSlide.js
$(document).ready(function(){
var current_title = $(document).attr('title');
if(current_title == 'Introduction to OneDrive')
getOneDriveFiles();
});
function getOneDriveFiles(){
//PnP call here
$pnp.setup({
baseUrl: "/TrainingResourceCenter/O365Training/"
});
$pnp.sp.web.getFolderByServerRelativeUrl("/TrainingResourceCenter/O365Training/Shared Documents/OneDrive/").files.orderBy("Title").get().then(function(f){
console.log(f);
var files = '';
$.each(f, function(index, value){
var filesHtml = "<div class='file'>" +
"<a href='" + value.ServerRelativeUrl + "'><img src='/O365Training/PublishingImages/wordThumbSmall.png' width='75px' height='75px' /></a>" +
"<a href='" + value.ServerRelativeUrl + "'><p id='fileTitle' margin-top: 10px>" + value.Title + "</p></a>" +
"</div>";
files = files + filesHtml;
});
$(".files").append(files).window.open(files);
});
}
<div id="filesDiv" class="row" style="padding-left: 15px;">
<div class="files" target="_blank"></div>
</div>
<script type="text/javascript" src="/publiccdnlib/apps/O365-Slider/o365FileSlide.js"></script>
https://i.stack.imgur.com/VBmcc.png
If anyone could give me some pointers, I would really appreciate it! Thanks.