Monday, April 07, 2008

More JavaScript, More "duh"

Another JavaScript "duh" moment. (You can see my previous JavaScript "duh" moment from last week here: http://nm1m.blogspot.com/2008/04/javascript-duh-moment.html ). A lot of times I want links to fire off JavaScript events, but to still look / taste / feel like links. Previously I have done it like this:

<a href="#" onClick="ColdFusion.Window.create('etc', 'etc.cfm');">
The upshot to this technique is that you get a link that looks and acts like a link. The minus is that when you click it, it appends a hash mark (#) to the end of your url. Not a big deal, but still.

On Friday, at the fabulous Salt Lake RIA Dev Shed, I learned another little "duh" JavaScript technique. Rather than trying to explain it, I will just show. You can do the same thing as the above like this:

<a href="javascript:ColdFusion.Window.create('etc', 'etc.cfm';">

Huzzah for cheap little JavaScript tricks!