Archives for May 2009
A tag more specfically, to open in a new window.
The most popular and incorrect way is using the
<a href="http://www.example.com/" target="_blank">Using Target</a>
target attribute was meant to direct content to load in a specific frame. In this case the keyword directs the browser to load the page in a new window, but with frames long dead and gone this little gem lives on as a reason people “can’t use HTML Strict.”:
<a href="#" onclick="window.open('http://www.example.com/');">Using Onclick</a>
<a href="#" onclick="window.open('http://www.example.com/'); return false;">Using Onclick</a>
<a href="http://www.example.com/" onclick="window.open('http://www.example.com/'); return false;">Improved use of onclick</a>
Using “return false;” stops the link from executing, allowing the URL to be put back in the
<a href="http://www.example.com/" onclick="window.open(this.href); return false;">Ideal use of onclick</a>
The redundancy is elimanted by using
this” refers to the current object in context, being the A tag. The “
href” references the A tags href property and the value (URL) contained within.
The end result is a small generic addition to any
If you rely heavily on Basecamp, a project management service by 37signals, then you’ve probably run into issues with erratic formatting in Writeboards and Messages. The contextual documentation is sparse at best and doesn’t explain how to stop the unintended formatting caused by the inadvertent use of reserved sequences.
Through a little experimentation, it seems that most HTML tags are left unencoded. While unexpected and also potentially problematic this behavior has it benefits. The
<pre> tags – and possibly more – turn off the Basecamp formatting engine and make it possible to preserve text that would otherwise be mis-formatted.
So next time you notice strange formatting, try surrounding your text in either
<pre> tags. Remember that while these tags won’t show up in the message itself, they will appear in any notification e-mail, but the same is true for standard Basecamp formatting.