Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai All

How to close alert message automatically using javascript

alert("hai");

please help me

Thanks n Advnce
Aatif
Posted
Comments
Thanks7872 9-Jul-13 8:01am    
'close alert message automatically' means what?
BiteForce 9-Jul-13 8:02am    
I think, this is impossible :/.
Aatif Ali from Bangalore 9-Jul-13 8:06am    
if u are using like alert("hi"); .It will Pop up a window with displaying the message "hi" normally this window don't close automatically(Close means hide)whenever u click on OK button then it will disappear.I need to hide these window automatically after a specified time.

Try this:

closing-popup-window-after-3-seconds[^]

hope it helps :)
 
Share this answer
 
Comments
Thanks7872 9-Jul-13 8:17am    
Good one..↑voted..!
Uday P.Singh 9-Jul-13 8:22am    
thanks Rohan!
I think its not possible to close javascript alert. Rather you can use any custom popup dialog box and then you have full control to set timeout to close the box.
 
Share this answer
 
Comments
Aatif Ali from Bangalore 10-Jul-13 0:45am    
Thanks Brothr...Y r right...i solved this using a custom control
Actually issue related with alert() function...

First I am Created one div like as follows

<div id="divReAssignDialog">Your session will expire in another 1 minute(s)! Please respond before the session expires</div>

XML
<script language="javascript" type="text/javascript" charset="utf-8">

            $("#divReAssignDialog").dialog({
                width: 400,
                height: 150,
                autoOpen: false,
                modal: true,
                resizable: false,
                autoResize: true,
                close: function () { }
            });

   

            var authorized = "<%=  HttpContext.Current.User.Identity.IsAuthenticated.ToString().ToLower() %>";
            if (getAbsolutePath().toLowerCase() == 'sessionexpired.aspx') {
                authorized = "false";
                //alert(authorized);
            }
            if (authorized == "true") {
                var sessionTimeoutWarning = "<%= Session.Timeout %>";
                sessionTimeoutWarning = sessionTimeoutWarning - 1;
                var sessionTimeout = "<%= Session.Timeout %>";
                var sTimeout = parseInt(sessionTimeoutWarning) * 60 * 1000;
                setTimeout('SessionWarning()', sTimeout);
                function SessionWarning() {
                    $("#divReAssignDialog").dialog("open");
                }

            }
        </script>


Now this div is closing automattically...

AAtif-Bangalore
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900