"Zouplaz" <po***@pouet.co m> wrote in message
news:Xn******** ************@21 2.27.42.77...
Hi, I'm trying find a solution to display a contextual helptext when
mouse
enters a form element (IE6 and Firefox 1.0)
The input tag :
<input name="message.t itle" helptext="Help message" value="" size=80>
The code :
var e = document.mainfo rm.elements;
for(i=0;i<e.len gth;i++)
{
var formObject = e[i];
if(formObject.h elptext != null)
{
formObject.onmo useover=mouseOv erHandler;
formObject.onmo useout=mouseOut Handler;
}
}
The above code works under IE6 but not with Firefox, nothing happen
because
formObject.help text is undefined.
What's wrong ? Does Firefox not support custom properties ?
By doing what you are doing, you've created markup that won't validate.
But ignoring that for now:
<form name="mainform" >
<input name="message.t itle" helptext="Help message" value="" size=80>
</form>
<script type="text/javascript">
var e = document;
if ((e = e.forms) && (e = e.mainform) && (e = e.elements))
{
for (i = 0; i < e.length; i++)
{
var ctl = e[i];
if (ctl.getAttribu te && ctl.getAttribut e('helptext'))
{
ctl.onmouseover =function() { alert('Over: ' +
ctl.getAttribut e('helptext')); };
ctl.onmouseout= function() { alert('Out: ' +
ctl.getAttribut e('helptext')); };
}
}
}
</script>
Tested and working in IE 6.0.2900, Firefox 1.0, Opera 7.54u2, Mozilla
1.0.2 and Mozilla 1.7.5.
Note that Mozilla 1.0.2 only fires the onmouseover, the other browsers
seem to fire both events moving over and out.
--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ -
http://jibbering.com/faq