Thursday, March 28, 2013

Open Sharepoint document Library PDF files in New window

STEP1:


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 HTMLEdit 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:

Thursday, March 21, 2013

Don't Show Missing Image Icon Suppose you have html page that will display users profile with profile images and if image is not present, automatically missing image icon is appearing, it's looks unprofessional. We can hide this icon or replace with the default image. Simply Hide the missing image icon using Javascript: