【问题标题】:Retrieving the URL of a list item's display form and ID in javascript using sharepoint使用 sharepoint 在 javascript 中检索列表项显示表单的 URL 和 ID
【发布时间】:2014-10-14 15:16:55
【问题描述】:

目前我已尝试将 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 部分输出为 undefined,并且该站点内还有一个需要包含的子站点。以粗体突出显示的是可变字段:

http://sharepoint_site/sub_site/**current_document_lib**/forms/dispform.aspx?**ID=1**

目前输出为:

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

有什么想法吗?

【问题讨论】:

  • 你使用的是sharepoint 2010?
  • 使用 2013 年,似乎通过使用 window.location.href 并使用 replace() 将 'AllItems' 替换为 'DispForm' 解决了问题

标签: javascript list url sharepoint


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-28
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    相关资源
    最近更新 更多