下面是用于使用 Web 服务显示列表项附件的脚本。
<script type="text/javascript" src="/Test/js/SPAPI_Core.js"></script>
<script type="text/javascript" src="/Test/js/SPAPI_Lists.js"></script>
<script type="text/javascript">
function getAttachments(List,ID){
var lists = new SPAPI_Lists('Your File name');
var items = lists.getAttachmentCollection(List,ID);
if (items.status == 200){
var rows = items.responseXML.getElementsByTagName('Attachment');
var str="";
for (var i=0; i<rows.length; i++){
temp=rows[i].childNodes[0].nodeValue;
fileName=temp.substring(temp.lastIndexOf('/')+1);
str+='<a href="'+temp+'" target="_blank">'+fileName+'</a>'+"<br />";
}
document.getElementById("att"+ID).innerHTML = str;
}else{
alert('There was an error: ' + items.statusText);
}
}
</script>
<xsl:if test="normalize-space(@Attachments) != '0'">
<div id="att{@ID}" style="padding: 10px;"></div>
<script type="text/javascript">
getAttachments("Posts",<xsl:value-of select="@ID"/>);
</script> </xsl:if>
reference URL: http://www.codeproject.com/Articles/31895/Displaying-Attachments-with-the-Data-View-Web-Part
上面的脚本是用来显示附件的……但是没用……
如果我遗漏了什么,请帮助我
提前致谢