Created
December 24, 2015 11:24
-
-
Save sksnips/af70704d30b4b3ce5779 to your computer and use it in GitHub Desktop.
HTML snippet is used to retrieve the creation date and modified date of a web site 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
<!-- How to get the Created date and Last Modified date of a Site --> | |
<!-- HTML Content --> | |
<div id="myapp"></div> | |
<!-- Script Content --> | |
<script type='text/javascript'> | |
var oWeb; | |
function getwebdetails() | |
{ | |
var clientContext = SP.ClientContext.get_current(); // equivalent to SPContext.Current | |
oWeb = clientContext.get_web(); //Gets the current Web Object | |
//clientContext.load(oWeb); - Load all properties for a web | |
clientContext.load(oWeb,'Title', 'Created', 'LastItemModifiedDate'); | |
clientContext.executeQueryAsync(onSucceeded,onFailed); | |
} | |
function onSucceeded() | |
{ | |
var strmsg = ""; | |
strmsg += "<b>Web Title:</b> " + oWeb.get_title() +"<br/>"; | |
strmsg += "Created Date: "+ oWeb.get_created()+"<br/>"; | |
strmsg += "Last Modified Date: "+ oWeb.get_lastItemModifiedDate(); | |
document.getElementById("myapp").innerHTML = strmsg; | |
} | |
function onFailed(sender, args) | |
{ | |
try | |
{ | |
console.log('Error: ' + args.get_message()); | |
} | |
catch (err) | |
{ | |
} | |
} | |
ExecuteOrDelayUntilScriptLoaded(getwebdetails, "sp.js"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment