[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [Trac] Adding javascript to Trac external links Noah Kantrowitz Sat Sep 09 09:37:57 2006

I am working on a plugin to deploy google analytics, check back in a week. :)


Toli Kuznets wrote:

I couldn't find an answer to this by searching through the archives,
so apologies if this has been covered already.

Is there a straightforward and simple way of modifying certain kinds
of external trac links to contain javascript events?

For example, if i wanted to implement an "onClick" javascript function
when certain links were clicked (to track downloads with Google
Analytics), what's the best way to approach it?
I want my resulting HTML to look like this:
<a href="http://www.example.com/files/map.pdf"
onClick="javascript:urchinTracker ('/downloads/map'); ">

I've tried using the {{{ #!html }}} HTML processor to add javascript
explicitly but that has been specifically disallowed as of bug 983.

Are there any other suggestions? i'd rather not put javascript
directly into CSS. Is there a plugin that will allow me to implement
this functionality?

thanks in advance.

Trac mailing list