Edit the view page by selecting Site Actions Edit Page.
STEP 2:
Click on “Add Web Part” and then select the Content Editor Web part from “Media and Content” category.
STEP 3:
Click on Content Editor web part
And then from ribbon select the Format Text HTMLEdit HTML Source
STEP 4:
Copy and paste the below given JavaScript code in HTML Source and click on OK.
------------------------------------------------- CODE -------------------------------------------------------
<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("OpenPDFInNewWindow()");
function OpenPDFInNewWindow()
{
var aAllLinks = document.links;
for(var i=0;i<aAllLinks.length;i++)
{
var oA = aAllLinks[i];
var sHREF = oA.href.toLowerCase();
if(sHREF.indexOf(".jpg") > 0
sHREF.indexOf(".pdf") > 0)
{
oA.onclick=function()
{
var w=window.open(this.href,'_blank','');
if(w) {
w.focus();
return false
};
return true;
}
}
}
} </script>
------------------------------------------------- CODE END-------------------------------------------------------
STEP 5:
Edit the Content Editor web part and set the options as below:
Referred URLs, please check below URLs for more details:
No comments:
Post a Comment