Skip to content

Instantly share code, notes, and snippets.

@javierguerrero
Created October 4, 2014 22:06
Show Gist options
  • Save javierguerrero/a9f5c0e568204b980f6f to your computer and use it in GitHub Desktop.
Save javierguerrero/a9f5c0e568204b980f6f to your computer and use it in GitHub Desktop.
GetWebIDWithJavaScript.js
<script>
ExecuteOrDelayUntilScriptLoaded(PageLoad, "sp.js");
function PageLoad() {
debugger;
this.ctx = SP.ClientContext.get_current();
this.web = ctx.get_web();
this.ctx.load(this.web);
ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
debugger;
alert(this.web.get_id());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment