On a SharePoint 2013 document library I have the following JavaScript function attached to the onclick event for each file:
function logAccess(fp) {
var userID = dsource.user.userid.substring(7);
var userName = dsource.user.userName;
var fPath = '\\\\server\\folder\\subfolder\\subfolder2\\subfolder3\\subfolder4\\subfolder5\\';
var fso = new ActiveXObject('Scripting.FileSystemObject');
if (fso.FolderExists(fPath)) {
var s = fso.CreateTextFile(fPath + tStamp + '.txt');
s.writeline(userID + '|' + userName + '|' + fp);
s.Close();
}
}
This creates a .txt file that tells me who accessed which file when, and saves it to a network drive location (fPath).
It works as expected on Internet Explorer, but since it uses ActiveX it doesn't work on Chrome and I don't have the option to enable IE Tab extension for Chrome.
I've tried using the filesaver.js API and it gets as far as creating a .txt file and downloading it, but it downloads to the user's default download folder (I can't specify a save location path). See below:
function logAccessChr(fp) {
var userID = dsource.user.userid.substring(7);
var userName = dsource.user.userName;
var content = userID + '|' + userName + '|' + fp;
var filename = tStamp + '.txt';
var blob = new Blob([content], {
type: "text/plain;charset=utf-8"
});
saveAs(blob, filename);
}
Can anyone think of a different approach to accomplish this on Chrome? Any suggestion is welcome.