Created
October 4, 2014 22:06
-
-
Save javierguerrero/a9f5c0e568204b980f6f to your computer and use it in GitHub Desktop.
GetWebIDWithJavaScript.js
This file contains hidden or 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
<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