Programmer's Guide > Programming and Scripting Techniques > Events > Event Handlers > JScript
  
JScript
In JScript, the EventListener interface is implemented by declaring a constructor of the same name. Note, that because of the way JScript works, the interface constants like Node.ELEMENT_NODE are not available. Otherwise, the clickEvent function is the same as the in the JavaScript example. The main difference is in how the listener object is created.
function EventListener( )
{
this.handleEvent = clickEvent;
}
function clickEvent(event)
{
var node = event.target;
var context = "";
while (node != null) {
if (node.nodeType == 1 /*ELEMENT_NODE*/) {
context = "(" + node.nodeName + context;
}
node = node.parentNode;
}
Application.print(context + "\n");
event.stopPropagation();
}
var doc = Application.activeDocument;
var listener = new EventListener();
doc.addEventListener("click", listener, true);