Results 1 to 3 of 3

Thread: How can I use javascript to pop up an image with a key-mouseover action?

  1. #1
    Join Date
    Jun 2006
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I use javascript to pop up an image with a key-mouseover action?

    What I want to do is have a mouseover image pop up work like this script does, but only when a key (I don't really care which key) is pressed while the mouseover happens. Someone suggested that javascript would probably be the best way to do this, so I'm hoping someone here can help me out.


    thanks!

  2. #2
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is by NO means a solution (as I am new to js myself), but more so a representation of the required logic as I understand it...psuedo-code if you will.

    Code:
    document.onkeydown = setPressedKey();
    document.onkeyup = unsetPressedKey();
    
    function setPressedKey(){
         //textbox value = pressed key
         txtPressedKey.value = event.keyCode;
    }
    function unsetPressedKey(){
         //clear box value
         txtPressedKey.value = '';
    }
    function MouseOver(){
         //if box is empty, no key is pressed
         if(txtPressedKey.value != '')
         {
              //do stuff
              alert("MouseOver with Key Pressed");
          }
          else
          {
              alert("MouseOver with no Key Pressed");
          }
    }
    Last edited by warrenw; 05-13-2009 at 08:01 PM. Reason: Left off text: Is this what you are trying to accomplish?

  3. #3
    Join Date
    Jun 2006
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks - if you also have any suggestions how to incorp the popup into that I'd be grateful to! (you know way more about js coding than I do)


    Glen

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
  •