$(document).ready(
function ()
{
// has to be on an interval for grouped doc libraries
// where the actual links are loaded only once a group
// is expanded
setInterval(
function ()
{
$("a[onclick*='return DispEx'][target!='_blank']").attr("target", "_blank").removeAttr("onclick");
// document type icons
$("td.ms-vb-icon>img[onclick]:not([documentUrl])")
.click(function (e)
{
window.open($(this).attr("documentUrl"), "_blank");
e.stopPropagation();
e.preventDefault();
return false;
})
.each(function ()
{
$(this).attr(
"documentUrl",
$.trim(String($(this).attr("onclick"))
.split("=")[1]
.replace(/["'{}]/g, "")
.split(";")[0])
);
this.onclick = null;
});
},
500
);
}
);
注意:需要将上述代码放到:<script type=”text/javascript”>将此处文本用上面的替换
</script>里面
另外,也可以将上面的js代码保存到一个js文件中,然后上传到sharepoint的一个文档库里,比如网站资产,获取上传后的js路径,然后通过下面的代码放入"内容编辑器web部件":
<script type="text/javascript" src="http://*****/SiteAssets/openinnewwindow.js"></script>
这样以后出问题,直接编辑js文件即可。
参考:http://www.benramey.com/2011/04/25/opening-all-sharepoint-2010-documents-in-a-new-window/(国外网站,打不开请用代理或直接自己想办法)
方法二:
直接将下述代码通过内容编辑器webpart放到文档库页面(AllItems.aspx)中: