使用sharepoint在javascript中检索列表项的显示表单和ID的URL
目前,我已尝试将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; .
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”解决了问题