Show flash message and notification in SharePoint page in SharePoint 2013

Show flash message and notification in SharePoint page in SharePoint 2013
SharePoint deveopment training course

In this post, we will discuss how to show a flash message in home page in SharePoint 2013 using JavaScript. The flash message will be displayed in a different background color. And the notification will appear on the right side of the page.

Also, you can check out some posts on:
Show SharePoint Survey Friendly message using jQuery

Configure Site Access Request in SharePoint 2013

E-mail notification using PowerShell script in Office 365

SharePoint 2013 provides SP.UI.Status class to add a status message to SharePoint page.

Below is the code to show status message:

<script type=”text/javascript”>
var statusId = ‘ ‘;
ExecuteOrDelayUntilScriptLoaded(ShowStatusMessage, “sp.js”);
function ShowStatusMessage()
{
this.statusId = SP.UI.Status.addStatus(“NewsFlash”, “This is is a testing site.”);

SP.UI.Status.setStatusPriColor(this.statusId, “yellow”);

}
</script>

It will appear like below:

Show flash message and notification in SharePoint page in SharePoint 2013
Show flash message and notification in SharePoint page in SharePoint 2013

Remove Status Message:
The below code to remove status message:

<script type=”text/javascript”>
function RemoveStatus() {
SP.UI.Status.removeStatus(statusId);
statusId = ”;
}
</script>

<input id=”buttonRemoveStatus” type=”button” value=”Remove Status” onclick=”RemoveStatus()” />

Show Notification Message:
<script type=”text/javascript”>
var notifyId = ”;
function AddNotificationMessage() {
notifyId = SP.UI.Notify.addNotification(“This is a notification”, true);
}
</script>

<input id=”btnNotificationMessage” type=”button” value=”Add Notification” onclick=”AddNotificationMessage()” />

The notification will be appear like below:

Show flash message and notification in SharePoint page in SharePoint 2013
Show flash message and notification in SharePoint page in SharePoint 2013

Remove Notification Message:
<script type=”text/javascript”>
var notifyId = ”;
function RemoveNotificationMessage() {
SP.UI.Notify.removeNotification(notifyId);
notifyId = ”;
}
</script>

<input id=”btnRemoveNotificationMessage” type=”button” value=”Remove Notification” onclick=”RemoveNotificationMessage()” />

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →