jsdom: how can I access the event listeners of an element

550 views
Skip to first unread message

Zhami

unread,
Jun 24, 2011, 11:06:47 AM6/24/11
to nodejs
I am using the jsdom module to load in a large HTML document, and am
using jQuery to navigate the DOM. I have a case where I need to access
the function body of an event listener (onclick). The event listener
was added in the source HTML:

<a href="#" onclick="javascript:window.open('http://restOfURL>');
return false;"></a>

The onclick attribute of the DOM element is undefined.

btw: what I really want to do is get the URL, so if there is some
other way to do that, such would meet my needs.

tia.

Zhami

unread,
Jun 24, 2011, 11:21:13 AM6/24/11
to nodejs
I have hacked a way to get the info I want,

e._attributes._nodes.onclick._childNodes[0]._text

(where e is the element)

but I wonder if there is something more "stable"
Reply all
Reply to author
Forward
0 new messages