Hello all,
I have a problem that how i get source element from event ‘e’ in following example.
I given onfocus event on body tag.
<body onfocus="Event.observe(document, 'keypress', handleKeyboardShortcuts);">
function for “handleKeyboardShortcuts” is fallows ——-
function handleKeyboardShortcuts(e)
{
var code; if (!e) e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
**
var sourceElement = e.srcElement.tagName;
alert(“source element: ”+ sourceElement);
var character = String.fromCharCode(code);
//key = 'space bar'
if(code 32 || character "")
{
//I do something here.
}
}
I used e.srcElement.tagName; but i don’t get source element.
Can any one tell me how i get it?
Thanks,
vikas.



Reply With Quote

Bookmarks