SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Confirm Window

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Confirm Window

    Hi, how do I display a confirm alert box, displaying an OK and CANCEL button?

    Upon the user clicking OK, how do I navigate to a different page?
    Upon the CANCEL button being clicked, how do I close the window/alert?

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Paul, I would recommend using confirm() rather than prompt() for this:

    Code JavaScript:
    if (confirm("Do you agree?")) {
        location.href = "differentpage.html";
    } else {
        // Confirmation cancelled
    }
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by magicman6452 View Post
    Upon the CANCEL button being clicked, how do I close the window/alert?
    The confirm dialog is canceled and closed when you do one of the following things:

    • Press the escape key on the keyboard
    • Press the cancel button
    • Click on the close button on the upper right (Windows)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •