"Zouplaz" <po***@pouet.com> wrote in message
news:Xn********************@212.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.title" helptext="Help message" value="" size=80>
The code :
var e = document.mainform.elements;
for(i=0;i<e.length;i++)
{
var formObject = e[i];
if(formObject.helptext != null)
{
formObject.onmouseover=mouseOverHandler;
formObject.onmouseout=mouseOutHandler;
}
}
The above code works under IE6 but not with Firefox, nothing happen
because
formObject.helptext 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.title" 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.getAttribute && ctl.getAttribute('helptext'))
{
ctl.onmouseover=function() { alert('Over: ' +
ctl.getAttribute('helptext')); };
ctl.onmouseout=function() { alert('Out: ' +
ctl.getAttribute('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*****@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq