SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: style question

  1. #1
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    style question

    hi!
    is there a way to change style to a textfield only when i press shift and click on it using javascript...
    couse i use onclick and on double click for other actions...
    any suggestion will be appreciated!!!
    thanx in advance!

  2. #2
    SitePoint Addict
    Join Date
    Jul 2000
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't know about shift-click, but you could create a right-click action:

    <span onclick="alert('left click');" oncontextmenu="alert('right click');return false">Test</span>

  3. #3
    SitePoint Member
    Join Date
    Oct 2004
    Location
    Bangalore
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this

    HTML Code:
    <body>
    <form name="form1" method="post" action="">
      <input type="text" name="textfield">
    </form>
    
    <script>
    function handler(evt){
    	if(!evt) evt = event;
    	if(evt.shiftKey){
    		this.style.background = '#e1e1e1';
    	}
    }
    document.form1.textfield.onclick = handler;
    </script>
    </body>
    Tested in IE6, Opera7.5 and NS7

    JS reference provides event.modifiers to verify pressing of ctrl, shift or alt key. But it is not supported by any of the above browsers

    - Kiran Makam

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you very much kiran...
    it works perfectly with mozila firefox like i wanted!!!
    cheers


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
  •