With the following html:
<div>
<a href='#link1' onclick='func()' >Link 1</a>
<a href='#link2' onclick='func()' >Link 2</a>
<a href='#link3' onclick='func()' >Link 3</a>
</div>
function func() {
var href = ??;
if( href.match(/#link1/) ) {
...
}
}
in Chrome (and IE?) can use this code
var href = window.event.target.href;
but window.event does not exist in Firefox
If the events were attached via addEventListener then could have e as an argument, but see no way to get the event passed to the onclick function when declared in html.
You do get the event as an argument, in the onclick handler itself. So you can do:
and then you can look at the event target in
func.