SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2008
    Location
    Coimbatore- India
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Focus to cancel button rather than to ok button..

    Hi,

    To get confirmation from the user before performing certain actions,we use javascript confirm box. The confirm box sets its focus to “Ok” button by default. I need to change this focus to “Cancel” button. Please let me know any solution to achieve this. And below is the code so far.


    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    function AskConfirmation()
    {
    	var comfirmValue = confirm("'Are you sure to Delete this mail?");
    	return comfirmValue;
    } 
    </script>
    </head>
    
    <body>
    <form name="form1" method="post" action="">
      <input type="submit" name="Submit" value="Submit" onClick="return AskConfirmation();">
    </form>
    </body>
    </html>

  2. #2
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,880
    Mentioned
    48 Post(s)
    Tagged
    0 Thread(s)
    Thats built into the browser, so not sure if thats possible. I would suggest creating a custom model popup and do what you need there

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The easiest thing is probably to reverse the question:
    Code JavaScript:
    function AskConfirmation()
    {
        var comfirmValue = confirm("This will delete the mail. Abort?");
        return !comfirmValue;
    }
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,880
    Mentioned
    48 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gambrinous View Post
    Clever!
    I second that. Very clever thinking AutisticCuckoo


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
  •