The code below renders a pop-up once a day for every user that logs into the SharePoint site. It was used in our SharePoint 2010 site for years and worked perfectly. Recently, we migrated from 2010 to 2016 and it does not work as well. It's inconsistent in its behavior. Some users get a popUp several times in a day and some don't. It's becoming quite annoying. I honestly don't think it's the code but I want to be sure. I think somehow the localstorage is getting cleared somehow but there's no way for me to confirm that. Any thoughts/ideas? We are using IE

 $(document).ready(function() {  
        SP.SOD.executeFunc('sp.js', 'SP.ClientContext', showModalPopUp);  
    function showModalPopUp() {  
        var lastodayDate = localStorage.getItem("connectedDate");
    var todayDate = new Date().toDateString().substring(4);
        //Set options for Modal PopUp  
        var options = {  
            url: '/SiteAssets/code/PopUp.html', 
            title: 'Privacy and Security',  
            allowMaximize: false,  
            showClose: true,  
            width: 680,  
            height: 470  

        if ((lastodayDate == null || lastodayDate == undefined) || (lastodayDate != todayDate)) {
       SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
       localStorage.setItem("connectedDate", todayDate);
       return false;  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.