Click here to Skip to main content
15,124,187 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


please help me

Thanks n Advnce
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:


hope it helps :)
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.
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>

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

                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";
            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() {


Now this div is closing automattically...


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