Yanyan Yanyan - 5 months ago 15
jQuery Question

Javascript confirm box, if cancel is clicked, it will not reload the page

Is there away that the confirm box appeared, if i clicked "ok" it will go to another page and if i clicked "cancel" it will just stay and the current page will not reload again? THANK YOU.

Answer
function reload()
{
    var r=confirm("Do you want to leave page!");
    if (r)
    {
        //write redirection code
        window.location = "http://www.yoururl.com";
    }
    else
   {
        //do nothing
    }
}

call this function when you want to confirmation from user.........

Comments