Yanyan Yanyan - 1 year ago 88
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 Source
function reload()
    var r=confirm("Do you want to leave page!");
    if (r)
        //write redirection code
        window.location = "http://www.yoururl.com";
        //do nothing

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download