.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

SharePoint 2010: Session Welcome Message Using jQuery

Posted By:Sagar Pardeshi       Posted Date: February 14, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

SharePoint 2010: Session Welcome Message Using jQuery


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 then calculate an applied Session Message (like Good morning , Lunch time, Good evening, Time to go home, and if the time else then a message like Welcome, we will be able to modify our welcome message accordingly.

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

Test it out on a single page!

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 to 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 > a.ms-menu-a > span');
var UserName = WelcomeMenuContent.text();
var FirstName = UserName.split(" ")[0];
var Display;
var Digital = new Date()
var Hours = Digital.getHours()
Morning = 'Good morning' + " " + FirstName;
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) 
}); </script>



In these article pros our modification to the Welcome menu can easily support multiple sessions.

A simple use of jQuery that easily adds a bit of customization.



 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend