I’m using a library which has already defined an onclick event handler on a hyperlink eg:
<a onclick="$('#myDiv').load('/?__=634285190817664832&sort=Id&sortdir=ASC&page=1 #myDiv');" href="#">1</a>
How can I get the value of the ‘url’ parameter?
Updated Answer
…after tobyodavies pointed out (in the nicest of ways) that I was being thick. If you explicitly retrieve the attribute, rather than the reflected property, we’ll get back the string from the DOM, not a function, and so don’t have to worry about function decompilation (see notes below). The remainder of the below is a bit paranoid (because I originally was working from function decompilation), but still:
Live example
Original Answer
Note that here there be dragons. The value of the
onclickreflected property by the time you’re accessing it in the DOM is a function object on most browsers, and so you’ll have to useFunction#toString, which has never been standardized and some mobile browsers are known to just return “[object Function]”. Most desktop browsers return a decompiled version of the event handler, but that can change at any time.But now you’re aware of the dragons, you can get it that way. Here’s a somewhat paranoid approach:
Live example