<script language="ecmascript" type="text/ecmascript">
var clientContext = null;
var oWeb = null;
var user = null;
function getUserInfo() {
clientContext = new SP.ClientContext.get_current()
oWeb = clientContext.get_web();
user = oWeb.get_currentUser();
clientContext.load(user);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
var message = "User Information";
message += "\n User Name: " + user.get_title();
message += "\n Login Name: " + user.get_loginName();
alert(message);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
<input id="btnGetUserInfo" onclick="getUserInfo()" type="button" value="Get Current Login User"/>