PDA

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



Glen_S
05-13-2009, 03:18 PM
What I want to do is have a mouseover image pop up work like this script (http://www.dynamicdrive.com/style/csslibrary/item/css-popup-image-viewer/) 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!

warrenw
05-13-2009, 08:00 PM
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.



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");
}
}

Glen_S
05-14-2009, 08:20 PM
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