Search This Blog

Tuesday, March 25, 2008

Display Current User Name in a page

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);
document.write(nameOnly);
</script>

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

welcome.png

No comments:

Post a Comment