Search code examples
javascriptalerthttp-redirect

Go to URL after OK button if alert is pressed


I need to make sure that when the user clicks OK in a JavaScript alert window, the browser moves to a different URL. Is this possible?


Solution

  • I suspect you mean in a confirm window (ie. Yes/No options).

    if (window.confirm('Really go to another page?'))
    {
        // They clicked Yes
    }
    else
    {
        // They clicked no
    }