<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("loadScript");
function loadScript()
{
ExecuteOrDelayUntilScriptLoaded(findUser, 'sp.js');
}
function findUser()
{
cxt = new SP.ClientContext.get_current();
web = cxt.get_web();
this._currentUser = web.get_currentUser();
cxt.load(this._currentUser);
cxt.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod),
Function.createDelegate(this, this.onFailureMethod));
}
function onSuccessMethod(sender, args)
{
alert('Welcome ' + this._currentUser.get_title());
}
function onFaiureMethod(sender, args)
{
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
0 Comments