Firefox custom properties problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zouplaz

    #1

    Firefox custom properties problem

    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 ?


    Thanks

  • Grant Wagner

    #2
    Re: Firefox custom properties problem

    "Zouplaz" <pouet@pouet.co m> wrote in message
    news:Xns9606C1B AD994EZoupla@21 2.27.42.77...[color=blue]
    > 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 ?[/color]

    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 <gwagner@agrico reunited.com>
    comp.lang.javas cript FAQ - http://jibbering.com/faq


    Comment

    • Zouplaz

      #3
      Re: Firefox custom properties problem

      Grant Wagner - gwagner@agricor eunited.com :
      [color=blue]
      >
      > 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.
      >[/color]

      Thanks a lot for your answer, I'll try it today !

      Comment

      Working...