Created
December 24, 2015 11:27
-
-
Save sksnips/40f4e4855257b38767ea to your computer and use it in GitHub Desktop.
HTML snippet used to retrieve the SharePoint web title using jsom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- HTML Content --> | |
<div id="myapp"></div> | |
<!-- Script Content --> | |
<script type='text/javascript'> | |
var oWeb; | |
function getwebtitle() | |
{ | |
var clientContext = SP.ClientContext.get_current(); // equivalent to SPContext.Current | |
oWeb = clientContext.get_web(); //Gets the current Web Object | |
clientContext.load(oWeb); | |
clientContext.executeQueryAsync(onSucceeded,onFailed); | |
} | |
function onSucceeded() | |
{ | |
document.getElementById("myapp").innerHTML = "<b>Web Title:</b> " + oWeb.get_title(); | |
} | |
function onFailed(sender, args) | |
{ | |
try | |
{ | |
console.log('Error: ' + args.get_message()); | |
} | |
catch (err) | |
{ | |
} | |
} | |
ExecuteOrDelayUntilScriptLoaded(getwebtitle, "sp.js"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment