SharePoint Show Welcome message session wise Using jQuery

This SharePoint 2010 tutorial explains, how to customize welcome message session wise using jQuery in SharePoint 2010 page. This article shows how to work with Welcome Message Session Wise. You’ll also find some plain old good JS date stuff that can be useful when you need to check times.

We want to welcome our users in their Office timing Session. We can use how to work with variables to retrieve the Current time hours Calculate applied Session Message(like Good morning, Lunchtime, Good evening, Time to go home, and if time else then messages like Welcome, we will be able to modify our welcome message accordingly.

We are ready to take a look at the result. Simply switch the display Session in the welcome menu to see the result of our work.

SharePoint Show Welcome message session wise Using jQuery
SharePoint 2010: Show Welcome message session wise Using jQuery

Add a Content Editor Web Part to your page and in the ribbon search for the HTML Source Editor for this Web Part. You can add your code in this editor to test the result on the page where the Web Part is found.

Code to add in the HTML Source Editor of the Content Editor Web Part (Don’t forget to add your jQuery library first as mentioned above):

<script src="/JS/jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var WelcomeMenuContent = $('.ms-welcomeMenu > > span');
var UserName = WelcomeMenuContent.text();
var FirstName = UserName.split(" ")[0];
var Display;
var Digital = new Date()
var Hours = Digital.getHours()
Lunch = 'Lunch time' + " " + FirstName;
Evening = 'Good evening' + " " + FirstName;
Night = 'Time to go home' + " " + FirstName;
TimeElse = 'Welcome' + " " + FirstName;
if (Hours >= 5 && Hours <= 11)
else if (Hours == 12)
else if (Hours >= 13 && Hours <= 17)
else if (Hours >= 18 && Hours <= 23)

You may like following jQuery tutorials:

I hope this will be helpful to show a welcome message using jQuery in SharePoint 2010/2013.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

Sagar Pardeshi

I am Developer working on Microsoft Technologies for the past 6+years. I am very much passionate about programming and my core skills are SharePoint, ASP.NET & C#,Jquery,Javascript,REST. I am running this blog to share my experience & learning with the community I am an MCP, MCTS .NET & Sharepoint 2010, MCPD Sharepoint 2010, and MCSD HTML 5,Sharepoint 2013 Core Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.