HLP: DHTML/Javascript

Discussion in 'Javascript' started by John Smith, Feb 25, 2004.

  1. John Smith

    John Smith Guest

    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.setAttribute('onClick',onClickArray[j]);


    Any help gratly appreciated!
     
    John Smith, Feb 25, 2004
    #1
    1. Advertising

  2. On Wed, 25 Feb 2004 03:32:37 GMT, John Smith <> wrote:

    > 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.setAttribute('onClick',onClickArray[j]);


    Try using

    formField.addEventListener('click',listener);

    or

    formField.onclick = 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="someHandler(this.form)">

    might become

    formField.onclick = function(evt) {
    someHandler(this.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
    d (replace ".invalid" with ".uk" to reply)
     
    Michael Winter, Feb 25, 2004
    #2
    1. Advertising

  3. John Smith

    John Smith Guest

    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:
    > On Wed, 25 Feb 2004 03:32:37 GMT, John Smith <> wrote:
    >
    >> 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.setAttribute('onClick',onClickArray[j]);

    >
    >
    > Try using
    >
    > formField.addEventListener('click',listener);
    >
    > or
    >
    > formField.onclick = 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="someHandler(this.form)">
    >
    > might become
    >
    > formField.onclick = function(evt) {
    > someHandler(this.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...
    >
     
    John Smith, Feb 27, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thiago Guedes

    HLP files

    Thiago Guedes, Jan 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,680
    Curt_C [MVP]
    Jan 13, 2004
  2. Rob Dob

    VS2005 C# is very BUGGY, please hlp

    Rob Dob, Nov 27, 2005, in forum: ASP .Net
    Replies:
    10
    Views:
    3,418
    Christopher Reed
    Dec 7, 2005
  3. karthika

    hlp me

    karthika, Jul 4, 2006, in forum: Java
    Replies:
    4
    Views:
    498
    Timo Stamm
    Jul 5, 2006
  4. Steve
    Replies:
    1
    Views:
    287
    Richard Cornford
    Apr 9, 2005
  5. SeanInSeattle
    Replies:
    7
    Views:
    137
Loading...

Share This Page