Derek wrote:
From what I remember, Safari doesn't support clickable labels at all.
Not so cool.
That's right.
Here's a little bit of JavaScript that levels the playing field and
will make labels clickable in any DOM-capable browser:
function focusLabels() {
if (!document.getElementsByTagName) return false;
var labels = document.getElementsByTagName("label");
for (var i=0; i<labels.length; i++) {
if (!labels[i].getAttribute("for")) continue;
labels[i].onclick = function() {
var id = this.getAttribute("for");
if (!document.getElementById(id)) return false;
var element = document.getElementById(id);
element.focus();
}
}
}
Call the function with your favourite addLoadEvent function or just use:
window.onload = focusLabels;
Of course, for most browsers, this function will make no difference
whatsoever: it's replicating the existing behaviour. But for the
exceptions like Safari, it will make *explicit* labels clickable.
--
Jeremy Keith
a d a c t i o
http://adactio.com/
******************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************