user4884336
user4884336

Reputation:

How to replace javascript message pop-up to Jquery message pop-up with only ok button option

I have 2 buttons on the pop-up window (Ok and Cancel) using javascript message pop-up window in below code. But i need only one button option (ok) using jquery or javascript message pop-up because i am not getting concept to disable cancel button using javascript.

Jquery message pop-up should work perfectly according to my below code.

I am working on time out session notification for a masterpage in ASP.NET and below is my javascript pop-up message code:

var active = confirm('Your session will expire in ' + (sess_expirationMinutes - sess_warningMinutes) +
        ' minutes (as of ' + now.toTimeString() + '), press OK to remain logged in ' +
                    'or press Cancel to log off. \nIf you are logged off any changes will be lost.');

Javascript code:

<script type="text/javascript">

var sess_pollInterval = 60000;
var sess_expirationMinutes = 3;
var sess_warningMinutes = 1;
var sess_intervalID;
var sess_lastActivity;

function initSession()
{    
    sess_lastActivity = new Date();
    sessSetInterval();

    $(document).bind('keypress.session', function (ed, e) {


        sessKeyPressed(ed, e);
    });
}

function sessSetInterval() 
{
    sess_intervalID = setInterval('sessInterval()', sess_pollInterval);
}

function sessClearInterval() 
{
    clearInterval(sess_intervalID);
}

function sessKeyPressed(ed, e) 
{
    sess_lastActivity = new Date();
}

function sessLogOut() 
{
    window.location.href = 'Logout.aspx';
}

function sessInterval()
{
    var now = new Date();
    //get milliseconds of differneces 
    var diff = now - sess_lastActivity;
    //get minutes between differences
    var diffMins = (diff / 1000 / 60);

    if (diffMins >= sess_warningMinutes)
    {
        //wran before expiring
        //stop the timer
        sessClearInterval();
        //promt for attention
   var active = confirm('Your session will expire in ' + (sess_expirationMinutes - sess_warningMinutes) +
            ' minutes (as of ' + now.toTimeString() + '), press OK to remain logged in ' +
                        'or press Cancel to log off. \nIf you are logged off any changes will be lost.');

        if (active == true)
        {
            now = new Date();
            diff = now - sess_lastActivity;
            diffMins = (diff / 1000 / 60);

            if (diffMins > sess_expirationMinutes)
            {
                sessLogOut();
            }
            else
            {
                initSession();
                sessSetInterval();
                sess_lastActivity = new Date();
            }
        }
        else
        {
            sessLogOut();
        }
    }
}
</script>

HTML code:

 <body onload="initSession()" >

<form id="form1" runat="server">
<div>

</div>
</form>
 </body>

Upvotes: 2

Views: 319

Answers (2)

Mihir Chauhan
Mihir Chauhan

Reputation: 141

You can use some JQuery from here :

http://www.freshdesignweb.com/jquery-javascript-popup-window.html

Upvotes: 0

potatopeelings
potatopeelings

Reputation: 41075

Replace confirm with alert. The confirm has both Ok and Cancel. alert has only Ok.

Upvotes: 1

Related Questions