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

Posted 鳄鱼的眼泪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于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
    });
}

  

以上是关于关于contentquery webpart的pdf文件如何在OOS上打开,并且所有文件在浏览器新起的页面打开?的主要内容,如果未能解决你的问题,请参考以下文章

Sharepoint 2007 数据视图 Webpart 自定义参数

使用 WSPBuilder 将 JavaScript、CSS 和其他内容添加到 WebPart

WebPart“元数据”?

powershell 安装sharepoint webpart:这个脚本1)备份当前部署的webpart,2)删除以前的webpart,3)添加新的wsp,4)dep

通过回调更新 WebPart

Webpart 功能未添加说明