Quantcast
Channel: Bolufer Blog - SharePoint & .NET language
Viewing all articles
Browse latest Browse all 49

Open Document Library documents in a new tab

$
0
0

Open Document Library documents in a new tab


Set this scritp on the page or master page.

<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

<script>

$
(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();
returnfalse;
})
.each(function()
{
$
(this).attr(
"documentUrl",
$
.trim(String($(this).attr("onclick"))
.split("=")[1]
.replace(/["'{}]/g,"")
.split(";")[0])
);
this.onclick =null;
});
},
500
);
}
);

</script>

Viewing all articles
Browse latest Browse all 49

Trending Articles