View Full Version : Proper way to have two onclick events within one anchor tag?

07-20-2011, 10:45 PM
OK, I'm filling in for a coworker on a radio stations website.

The station currently streams live online. I want to add an event tracking so I can track how many people are streaming. I'm really new to js, but I think I figured it out (keyword is "think"). However, there was already an onclick event within the anchor tag. Can I have two in the same tag? Is there a better way to do this?

<a href="/fmstream/listen.asx" onclick="window.open(this.href,'Listen','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar= no,fullscreen=no,dependent=no,width=400,height=400,status'); return false" onClick="pageTracker._trackEvent('Stream','Listen_Button','Stream_Live');">
<img src="/images/filecabinet/folder1/listen1.png" alt="listen1"></a>

07-20-2011, 11:49 PM
You could just do something like:

<a href="stuff" onclick="function1();function2();">

rather than have two onClicks. It will then execute function1() followed by function2()