I had a hard time trying to find the best article to develop SharePoint popup messages after page load. I was in the middle of developing a SharePoint Server site. I wanted to display a message or a banner to display something everytime a user accesses the SharePoint site. I did a lot of research and found this article which helped me from start to finish. This was the closest article I could find. I decided to create an article on C# Corner to help others on how to create a popup message on their SharePoint sites. The steps below can be applied to any version of SharePoint server version from 2010, 13, 16 or later.
Here are the steps -
Step 1
Create a text file in Notepad. Copy and paste this code. Save the file as Popup.aspx on the desktop. You can change the colors to h1(line 3), h2(Line 7), and p(line 11) sections. Customize the message header<h1> (line 22) and text set below the header <p> (line 23). Also, you can customize the name of the button in line 24 located value=
Create a text file in Notepad. Copy and paste this code. Save the file as Popup.aspx on the desktop. You can change the colors to h1(line 3), h2(Line 7), and p(line 11) sections. Customize the message header<h1> (line 22) and text set below the header <p> (line 23). Also, you can customize the name of the button in line 24 located value=
- <style>
- h1 {
- color: #000000;
- text-align: center;
- }
- h2 {
- color: #000000;
- text-align: center;
- }
- p {
- color: #000000;
- font-size: 1em;
- }
- input {
- font-family: "Segoe UI";
- font-size: 1em;
- }
- </style>
- <div id="myModal" class="modal fade" role="dialog">
- <div class="modal-dialog" style="font-family: 'Segoe UI'; width: auto; height: auto;">
- <div class="modal-content">
- <h1>Welcome to SharePoint!!!!!!</h1>
- <p>This is a SharePoint Message. </strong></p>
- <input type="button" href="#" value="OK" onclick="window.frameElement.cancelPopUp(); return false;" />
- </div>
- </div>
- </div>
Step 2
Create another text file and copy and paste this code. In the URL: section (line 5), replace [Type SharePoint URL HERE] with your SharePoint URL. Leave Site/Popup.aspx default. Save the file as Popup.js on the desktop.
Create another text file and copy and paste this code. In the URL: section (line 5), replace [Type SharePoint URL HERE] with your SharePoint URL. Leave Site/Popup.aspx default. Save the file as Popup.js on the desktop.
- <script language="javascript" type='text/javascript'>
- _spBodyOnLoadFunctionNames.push('showPopup');
- function showPopup() {
- var options = {
- url: "[Type SharePoint URL HERE]/SitePages/PopUp.aspx" };
- SP.UI.ModalDialog.showModalDialog(options);
- }
- </script>
Step 3
Launch SharePoint Central Administration.
Step 4
Select Site settings.
Launch SharePoint Central Administration.
Step 4
Select Site settings.




abc ChauhanPosted Jan 13, 2021, 12:44 PM
It is possible same pop up message in modern Sharepoint site? Can anyone help please?
John LiterPosted Jun 5, 2020, 11:29 AM
Can you add add multiple URLs to the JS file so dont have to upload it to every page?
joanna bPosted Aug 11, 2019, 9:53 PM
Hi! thanks for this. i followed your steps but the popup is only appearing in edit mode, or the site won't let me enter edit mode. any suggestions?
shaik rubinaPosted Aug 11, 2018, 12:56 AM
If he is a invalid user then another reg. Form will open. The code is not in .cs file it is in base project we have retrieve data from base project and that reg data should save in collections it is a wizard implementation window application any body have comment pls share with me
shaik rubinaPosted Aug 11, 2018, 12:53 AM
Continue,,
shaik rubinaPosted Aug 11, 2018, 12:52 AM
How to validate data present in login form to know whether he is a admin or user. If he is a admin should go to the form which contains all user information.