Over a million developers have joined DZone.

JavaScript for Windows 8 Apps: How to Access the User’s Display Name

DZone's Guide to

JavaScript for Windows 8 Apps: How to Access the User’s Display Name

· Web Dev Zone
Free Resource

Add user login and MFA to your next project in minutes. Create a free Okta developer account, drop in one of our SDKs to your application and get back to building.

Need to know the display name of the user currently logged in to Windows 8?  The task is easy!

To demonstrate, I created a new “Blank App” JavaScript project in Visual Studio 2012.  In the default.html file, I replaced the contents of the <body> tag with the following:

    <h1 id="displayName">(to be replaced by user's display name)</h1>
            function (name) {
                document.querySelector("#displayName").textContent = name;

When I run the application, my <h1> contents contain my display name.


Of course the JavaScript code above could be used in an external .js file as well.



Launch your application faster with Okta’s user management API. Register today for the free forever developer edition!


Published at DZone with permission of Michael Palermo, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}