Posts

Showing posts from June, 2017

SharePoint useful JavaScript objects, functions

There are several SharePoint inbuilt JavaScript objects / functions helps you to write script professional way and saves your time. The following are few you can explore more in SP.Init.debug.js and page sources. 1. _spPageContextInfo:   the object exists in sharePoint pages _spPageContextInfo.siteAbsoluteUrl:   returns the site collection url of the current web site. var siteUrl = _spPageContextInfo.siteAbsoluteUrl _spPageContextInfo.webAbsoluteUrl:   returns the current web site url. var webUrl = _spPageContextInfo.webAbsoluteUrl _spPageContextInfo.webServerRelativeUrl:   returns the current web relative url var webRelativeUrl = _spPageContextInfo.webServerRelativeUrl 2. SP.ScriptHelpers:   The function implemented in SP.Init.js and used across all scripts.  SP.ScriptHelpers.isNullOrEmptyString:   this method ensure the parameter is null or empty. var a; if(SP.ScriptHelpers.isNullOrEmptyString(a)) co...