Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用sharepoint在javascript中检索列表项的显示表单和ID的URL_Javascript_List_Url_Sharepoint - Fatal编程技术网

使用sharepoint在javascript中检索列表项的显示表单和ID的URL

使用sharepoint在javascript中检索列表项的显示表单和ID的URL,javascript,list,url,sharepoint,Javascript,List,Url,Sharepoint,目前,我已尝试将URL分解为以下几个部分: var items = SP.ListOperation.Selection.getSelectedItems(oList); for(var n in items) {.. var itemURL = window.location.protocol +'//'+ window.location.host +'/'+ oList.Title +'/Forms/DispForm.aspx?ID=' + items[n].id; .

目前,我已尝试将URL分解为以下几个部分:

var items = SP.ListOperation.Selection.getSelectedItems(oList);
for(var n in items)
{..
     var itemURL = window.location.protocol +'//'+ window.location.host 
     +'/'+ oList.Title +'/Forms/DispForm.aspx?ID=' + items[n].id;
..}
这会将oList.Title部分输出为未定义,并且站点中还包含需要包含的子站点。以粗体突出显示的是可变字段:

http://sharepoint_site/sub_site/**current_document_lib**/forms/dispform.aspx?**ID=1**
目前它的输出为:

http://sharepoint_site/undefined/forms/dispform.aspx?ID=1

有什么想法吗?

通过使用window.location.href并使用replace将'AllItems'替换为'DispForm'解决了问题:

 var finalURL = itemURL.replace('AllItems', 'DispForm');

您正在使用sharepoint 2010?使用2013,似乎通过使用window.location.href并使用replace将“AllItems”替换为“DispForm”解决了问题