Closing popup window after 3 seconds

前端 未结 8 1605
孤独总比滥情好
孤独总比滥情好 2020-12-03 18:02

I need to close the popup windows in the following after 3 seconds. How do I do it.


                  

        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 18:35

    Creating a global variable and reuse it in our code.

    var info = function (text, onClose, headerText) {
                  if (!headerText)
                    headerText = "Info";
        
                alert(text, null, onClose, headerText, true);
        }
        
        // Call this in own code where ever you need
        
        info("Message that going to close automatic.");
        hidePopUpMessage();
        
        // callback function to showing 3 sec.
        function hidePopUpMessage() {
                setTimeout(function () {
                    $("#pp-alert-close").click();
                    //$("#popup-close").click();
                }, 3000);
            }

提交回复
热议问题