I have to convert following function to javascript,
Sub document_onkeydown()
If window.event.keyCode = 27 Then
window.event.ReturnValue = false
ElseIf window.event.keyCode = 13 Then
If TypeName(window.event.srcElement) = "HTMLInputElement" Or TypeName(window.event.srcElement) = "HTMLSelectElement" Then
If window.event.srcElement.name <> "QuickSearch" Then
Call butSearch_OnClick
End If
End If
End If
End Sub
Can anyone help me to convert following points,
window.event.ReturnValue = false
TypeName(window.event.srcElement) = "HTMLInputElement"
window.event.srcElement.name <> "QuickSearch"
Thank you very much
[ 1 ]
window.event.ReturnValue = falseis similar toreturn falsein Javascript.It means returning from function when you have nothing to do in particular case.
[ 2 ]
event.srcElementpoints to the objects from which the event is generated.That is Similar to
event.currentTargetin Javascript. And theTypeName()retuns the type of that object, similar totypeof()in Javasript.[ 3 ]
event.srcElement.namereturns thenameattribute of the object from which the event occured.