web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Nishant Rana’s Weblog / Using JavaScript in custom ...

Using JavaScript in custom master page for SharePoint 2013 that uses SP.js.

Nishant Rana Profile Picture Nishant Rana 11,325 Microsoft Employee

Hi,

We recently had a requirement to show no of listitems on a particular list on every page within the site. So we decided to use the JavaScript that does so in our custom master page itself.

This is how we got it working

Adding the SharePoint script link that refers to the SP.js file in our custom html master page.

<!–MS:<SharePoint:ScriptLink ID=”ScriptLink21″ Name=”sp.js” runat=”server” OnDemand=”false” LoadAfterUI=”true” Localizable=”false”>–>
<!–ME:</SharePoint:ScriptLink>–>

And then executing our script using the following method i.e. after SP.js is loaded

function GetCount() {

// code that uses CSOM to get the count

}


ExecuteOrDelayUntilScriptLoaded(GetCount, “sp.js”);

Hope it helps.


Filed under: SharePoint, SharePoint 2010, SharePoint 2013 Tagged: SharePoint, SharePoint 2010, SharePoint 2013

This was originally posted here.

Comments

*This post is locked for comments