SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using two events together

    Hey Guys...
    I have css box with two form buttons in it ok and cancel,
    The javascript for cancel button is onclick='javascript:cancelalert(); I need this script to work even when I press the 'Esc' Key on the keyboard
    wht do i write further in the script..
    (In short button should work when 1. clicked and 2. on pressing the 'Esc' Keyboard key similar way OK button should work on pressing the 'Enter' key)

    Thanks
    Vicky...

  2. #2
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code javascript:
    onkeydown = function(e){
    	if ((e || window.event).keyCode == 27) {
    		cancelalert();
    		return false; //security measure
    	}
    };


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
  •