Sharing SharePoint

Always a rookie in the SharePoint World

Display Current User Name in a page

Posted by Jessica Wang on March 26, 2008

I had to display the current user name in a page within Sharepoint, So I created this javascript to get the name from the welcome link.

1. Enter the javascript within the page.aspx

 <!– Script for displaying name –>
     <script language=”javascript”  type=”text/javascript”>
   var Loginname = document.getElementById(“zz6_Menu”).innerHTML ;   
   var end = Loginname.indexOf(“<“); 
   var nameOnly = Loginname.substring(8, end);

There are 2 ways which you can get the Id which is highlighted in red.

1. Right the page and view source to get the ID

2. Using IE Developer Toolbar, click on the Name



3 Responses to “Display Current User Name in a page”

  1. […] Como mostrar el usuario logado en SharePoint mediante JavaScript. […]

  2. Enéas Gesing said

    Thank you man. This solved a problem today!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: