我需要从ms-unselectedtitle中提取ID,这是SharePoint 2007列表中ms-vb-title的子元素。然后将其与URL连接以打开新窗口。窗口需要使用window.open()方法打开,这样我就可以控制大小并关闭菜单。按计算列创建列表中的链接将不起作用,因为它只是在包含所有菜单的选项卡中打开一个新窗口。我发现这里的代码(“How to get ID value from tables nested in other tables with jQuery”)很接近,但它返回一个ID数组,而不是表行。我是javascript / jquery的新手,所以我有点卡住了。请注意,我正在使用的ID嵌入在列表的“标题”字段中。 Html部分在这里......
<TD class=ms-vb-title height="100%" sizset="50" sizcache011076027996994381="6">
<TABLE onmouseover=OnItem(this) id=284 class=ms-unselectedtitle height="100%"
cellSpacing=0 Type="" SUrl="" UIS="1024"
CId="0x010010381707B6E7FC45825D794C02F54155" CType="Item" MS="0" CSrc="" HCD=""
COUId="" OType="0" Icon="icgen.gif||" Ext="" Perm="0x400001f07ee71bef"
DRef="sites/site1/M/S/Lists/MAINT_ACTIONS" Url="/sites/site1/M/S/Lists
/MAINT_ACTIONS/284_.000" CTXName="ctx1" sizset="50" sizcache011076027996994381="6">
<TBODY beenthere="1">
<TR>
<TD class=ms-vb width="100%"><A onclick="GoToLink(this);return false;"
onfocus=OnLink(this) href="/sites/site1/M/S/Lists/MAINT_ACTIONS
/DispForm.aspx?ID=284" target=_self>Item <IMG class=ms-hidden border=0
alt="Use SHIFT+ENTER to open the menu (new window)." src="/_layouts/images
/blank.gif" width=1 height=1></A></TD>
<TD><IMG style="VISIBILITY: hidden" alt=Edit src="/_layouts/images
/menudark.gif" width=13></TD>
</TR>
</TBODY>
</TABLE>
</TD>
关闭的代码低于......
// filter out all tables with immediate parent td.ms-vb-title
// returns a collection
var ids = $('.ms-unselectedtitle').filter(function() {
return $(this).parent('td').hasClass('.ms-vb-title');
// from resulting collection, grab all IDs
}).map(function() {
return this.id;
// convert to array
}).get();
有人可以帮助我吗?请注意,我正在尝试从行中的可点击链接访问ID。
答案 0 :(得分:0)
我能够通过在SharePoint列表中创建三列来解决这个问题,最后一列将它们组合在一起。
getWin1 held ...onClick='javascript:window.open("... the first part of the
script and was made default text for this single line text column.
getWin2 held ...","_blank","toolbar=0,menubar=0,top=50,left=50,width=1024,
height=800,scrollbars=0,resizable=0,location=0");return false;'... the
second single line text column.
getUrl concatenated the url to the ID from the list.
=CONCATENATE("<span><input ",getWin1,getUrl,getWin2," type='image'
src='https://sof.socom.mil/sites/SORDAC/M/SharePoint_System_Files/Icons
/Magnification_16.png'/></span>")... was put into the last column to
combine the three columns.
我有HTML CEWP文本将其转换为HTML脚本。不是最佳解决方案,但它有效。请注意,...只标记脚本的开头和结尾。