关于contentquery webpart的pdf文件如何在OOS上打开,并且所有文件在浏览器新起的页面打开?

function SetHref(pdf) {
var c = pdf.href; var d = "http://eds.jd.com";
var f = "";
var g = "";
if (c.indexOf('sites') > -1) {
var e = c.split('/');
var i;
for (i = 0; i < e.length; i++) {
if (e[i] == "sites") {
break;
}
}
d += "/sites/" + e[i + 1]; var InfoUri = d + "/_api/site/rootWeb/webinfos";
$.ajax({
url: InfoUri,
method: "GET",
headers: { "accept": "application/JSON;odata=verbose" },
success: function (data) { var h = data.d.results;
var num = 0;
for (num = 0; num < h.length; num++) { var url = data.d.results[num].ServerRelativeUrl.split('/'); if (url[url.length - 1] == decodeURI(e[i + 2])) { break;
}
} if (num == h.length) {
f = e[i + 2];
for (var j = i + 3; j < e.length - 1; j++) {
f += "/" + e[j];
}
g = e[e.length - 1];
}
else {
d += "/" + e[i + 2];
f = e[i + 3];
for (var j = i + 4; j < e.length - 1; j++) {
f += "/" + e[j];
}
g = e[e.length - 1];
} Gethref(d, f, g, pdf); },
error: function (data) {
var d = data;
},
failed: function (data) {
var d = data;
},
async: true
});
} else {
var e = c.split('/');
f = e[3];
for (var j = 4; j < e.length - 1; j++) {
f += "/" + e[j];
}
g = e[e.length - 1]; Gethref(d, f, g, pdf);
}
} function Gethref(d, f, g, pdf) {
var fileInfoUri = d + "/_api/web/GetFolderByServerRelativeUrl('" + f + "')/Files";
$.ajax({
url: fileInfoUri,
method: "GET",
headers: { "accept": "application/JSON;odata=verbose" },
success: function (data) { var h = data.d.results;
for (var i = 0; i < h.length; i++) {
if (data.d.results[i].Name == decodeURI(g)) { pdf.href = d + "/_layouts/15/WopiFrame.aspx?sourcedoc={" + data.d.results[i].UniqueId + "}"; pdf.target = "_blank"; pdf.onclick = null; }
} },
error: function (data) {
var d = data;
},
failed: function (data) {
var d = data;
},
async: true
});
}

  

上一篇:Linux之RedHat7如何更换yum源


下一篇:python使用rabbitMQ介绍三(发布订阅模式)