www.webdeveloper.com
Results 1 to 4 of 4

Thread: rightclick and textbox

  1. #1
    Join Date
    Mar 2006
    Posts
    2

    rightclick and textbox

    I want to be able to right click on a text box and it will change the background color to red. If i rightclick on it again it will change it back to no color. Is this possible?

    The form will have multiple textboxes on it.

    Thanks,

    Joshua Tipton

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    Turn the following into a function and you'll do fine:
    Code:
    <input type="text" ...etc... onmousedown="
     var btn = (window.Event) ? event.which : event.button;
     if (btn == 2) {
         if (this.style.backgroundColor.substr(0,3)=='red') {
             this.style.backgroundColor = '';
         } else {
             this.style.backgroundColor = 'red';
         }
     }
     return true;">

  3. #3
    Join Date
    Mar 2006
    Posts
    2
    With that how can I make the IE menu not come up?

  4. #4
    Join Date
    Dec 2004
    Posts
    8,637
    window.oncontextmenu = function() { return false; };

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles