HLP: DHTML/Javascript

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

    HLP: DHTML/Javascript

    Hello all, I have a page that generates a form with dynamic rows of data.

    The dynamic part is done by javascript and I have added onClick, also
    tried onFocus, attribute in the dynamic field.

    In mozilla's it works like a charm and the DOM in mozilla shows input
    text field correctly with the onClick attribute

    IE however does not do anything, nada, nothing, even when I just specify
    a simple alert(); ????? Help (am I going stupid or is IE stupid ?)

    This is what I use to set the attribute, where the onClickArray contains
    the diffirent onclicks for the dynamic fields:

    formField.setAt tribute('onClic k',onClickArray[j]);


    Any help gratly appreciated!
  • Michael Winter

    #2
    Re: HLP: DHTML/Javascript

    On Wed, 25 Feb 2004 03:32:37 GMT, John Smith <jsmith@js.co m> wrote:
    [color=blue]
    > The dynamic part is done by javascript and I have added onClick, also
    > tried onFocus, attribute in the dynamic field.
    >
    > In mozilla's it works like a charm and the DOM in mozilla shows input
    > text field correctly with the onClick attribute
    >
    > IE however does not do anything, nada, nothing, even when I just specify
    > a simple alert(); ????? Help (am I going stupid or is IE stupid ?)
    >
    > This is what I use to set the attribute, where the onClickArray contains
    > the diffirent onclicks for the dynamic fields:
    >
    > formField.setAt tribute('onClic k',onClickArray[j]);[/color]

    Try using

    formField.addEv entListener('cl ick',listener);

    or

    formField.oncli ck = listener;

    instead. Note that the former is a DOM method, so you should use feature
    detection before using it - especially as IE doesn't support it. If
    detection fails, you could fall back on the latter.

    Be aware that 'listener', in both cases, is a reference to a function that
    expects a single argument: event[1]. If you have a handler that takes your
    own arguments, you can use an intermediary.

    <input ... onclick="someHa ndler(this.form )">

    might become

    formField.oncli ck = function(evt) {
    someHandler(thi s.form);
    }

    The operator, this, still refers the same input element in both cases.

    Does that help?

    Mike


    [1] IE is different - there are no expected arguments. It stores the event
    data in a different object, window.event. This event object also contains
    different properties than that of the standard event object. Typical
    Microsoft...

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    • John Smith

      #3
      Re: HLP: DHTML/Javascript

      Super thanks,

      and yes M$ has to screw every thing up ! did you hear that they are
      trying to patent the virual desktop that *nix had for the last 20 years,
      they even use KDE and gnome screen shorts in their patent.

      If I did not know better I would think that their new bussiness plan is
      to be just hated.

      Michael Winter wrote:[color=blue]
      > On Wed, 25 Feb 2004 03:32:37 GMT, John Smith <jsmith@js.co m> wrote:
      >[color=green]
      >> The dynamic part is done by javascript and I have added onClick, also
      >> tried onFocus, attribute in the dynamic field.
      >>
      >> In mozilla's it works like a charm and the DOM in mozilla shows input
      >> text field correctly with the onClick attribute
      >>
      >> IE however does not do anything, nada, nothing, even when I just
      >> specify a simple alert(); ????? Help (am I going stupid or is IE
      >> stupid ?)
      >>
      >> This is what I use to set the attribute, where the onClickArray
      >> contains the diffirent onclicks for the dynamic fields:
      >>
      >> formField.setAt tribute('onClic k',onClickArray[j]);[/color]
      >
      >
      > Try using
      >
      > formField.addEv entListener('cl ick',listener);
      >
      > or
      >
      > formField.oncli ck = listener;
      >
      > instead. Note that the former is a DOM method, so you should use feature
      > detection before using it - especially as IE doesn't support it. If
      > detection fails, you could fall back on the latter.
      >
      > Be aware that 'listener', in both cases, is a reference to a function
      > that expects a single argument: event[1]. If you have a handler that
      > takes your own arguments, you can use an intermediary.
      >
      > <input ... onclick="someHa ndler(this.form )">
      >
      > might become
      >
      > formField.oncli ck = function(evt) {
      > someHandler(thi s.form);
      > }
      >
      > The operator, this, still refers the same input element in both cases.
      >
      > Does that help?
      >
      > Mike
      >
      >
      > [1] IE is different - there are no expected arguments. It stores the
      > event data in a different object, window.event. This event object also
      > contains different properties than that of the standard event object.
      > Typical Microsoft...
      >[/color]

      Comment

      Working...