如何将列表的javascript链接放入html表?

时间:2022-12-07 01:27:21

I have created a script for a link to a sharepoint list of information. I am looking to display that in a html page. Wondering how to do this? My javascript code is below.

我已经创建了一个脚本,用于指向sharepoint信息列表的链接。我希望在html页面中显示它。想知道怎么做?我的javascript代码如下。

var clientContext = new SP.ClientContext();

var oList = clientContext.get_web().get_lists().getByTitle('Utilities Contract');

var camlQuery = new SP.CamlQuery();

var collListItem = oList.getItems(camlQuery);

clientContext.load(collListItem);

clientContext.executeQueryAsync( 
    function(){
        var listItemEnumerator = collListItem.getEnumerator();
        while (listItemEnumerator.moveNext()) {

            var oListItem = listItemEnumerator.get_current();

            var itemTitle = oListItem.get_item('Title');

            var itemId = oListItem.get_id();
    },
    function(sender, args){
        console.log('Request failed. ' + args.get_message() + 
        '\n' + args.get_stackTrace());
});

1 个解决方案

#1


0  

To call SharePoint JSOM API, it is necessary to put the script into SharePoint Page instead of normal html page as it needs to use SharePoint ClientContext which is not available in normal html page, you could add the script via ScriptEditor Web Part: 如何将列表的javascript链接放入html表?

要调用SharePoint JSOM API,有必要将脚本放入SharePoint页面而不是普通的html页面,因为它需要使用常规html页面中不可用的SharePoint ClientContext,您可以通过ScriptEditor Web部件添加脚本:

#1


0  

To call SharePoint JSOM API, it is necessary to put the script into SharePoint Page instead of normal html page as it needs to use SharePoint ClientContext which is not available in normal html page, you could add the script via ScriptEditor Web Part: 如何将列表的javascript链接放入html表?

要调用SharePoint JSOM API,有必要将脚本放入SharePoint页面而不是普通的html页面,因为它需要使用常规html页面中不可用的SharePoint ClientContext,您可以通过ScriptEditor Web部件添加脚本: