onreset and Mozilla

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

    onreset and Mozilla

    Hi newsgroup!

    The W3C HTML 4.01 recommendation states that "The onreset event occurs
    when a form is reset." Using Mozilla 1.4.1, how come that if I set
    onreset="return false;", the form is not reset at all? Is this a bug?
    I've attached an HTML page to reproduce the behaviour.

    Bye,
    Peter.

  • Peter Adolphs

    #2
    Re: onreset and Mozilla

    Peter Adolphs wrote:[color=blue]
    > The W3C HTML 4.01 recommendation states that "The onreset event occurs
    > when a form is reset." Using Mozilla 1.4.1, how come that if I set
    > onreset="return false;", the form is not reset at all? Is this a bug?
    > I've attached an HTML page to reproduce the behaviour.[/color]

    Hmmm, if I test the attachment directly in Mozilla Mail, it's behaving
    correctly. The described behaviour only shows up if the page is viewed
    in Mozilla Navigator... Well, now it really looks like a bug to me.

    Peter.

    Comment

    • kaeli

      #3
      Re: onreset and Mozilla

      In article <408E9D5A.80109 00@spammotel.co m>, LLCSVDYARTMJ@sp ammotel.com
      enlightened us with...[color=blue]
      > Hi newsgroup!
      >
      > The W3C HTML 4.01 recommendation states that "The onreset event occurs
      > when a form is reset." Using Mozilla 1.4.1, how come that if I set
      > onreset="return false;", the form is not reset at all?[/color]

      Because you cancelled the reset by returning false.
      Try onreset="alert( 'hi!')" and watch if it goes.
      [color=blue]
      > Is this a bug?[/color]

      I doubt it.


      --
      --
      ~kaeli~
      Is it possible to be totally partial?



      Comment

      • Peter Adolphs

        #4
        Re: onreset and Mozilla

        kaeli wrote:[color=blue]
        > In article <408E9D5A.80109 00@spammotel.co m>, LLCSVDYARTMJ@sp ammotel.com
        > enlightened us with...
        >[color=green]
        >>The W3C HTML 4.01 recommendation states that "The onreset event occurs
        >>when a form is reset." Using Mozilla 1.4.1, how come that if I set
        >>onreset="retu rn false;", the form is not reset at all?[/color]
        >
        > Because you cancelled the reset by returning false.
        > Try onreset="alert( 'hi!')" and watch if it goes.[/color]

        Well, but this is compliant to the spec. The alert window is shown when
        the form is reset. In my case, it is not reset since I return false. But
        why? Where does it say that returning false cancels the action of an
        event handler? That would mean that an event handler can undo an event
        which it is supposed to react to. ???

        Peter.

        Comment

        • Peter Adolphs

          #5
          Re: onreset and Mozilla

          Peter Adolphs wrote:[color=blue]
          > Peter Adolphs wrote:
          >[color=green]
          >> The W3C HTML 4.01 recommendation states that "The onreset event occurs
          >> when a form is reset." Using Mozilla 1.4.1, how come that if I set
          >> onreset="return false;", the form is not reset at all? Is this a bug?
          >> I've attached an HTML page to reproduce the behaviour.[/color]
          >
          > Hmmm, if I test the attachment directly in Mozilla Mail, it's behaving
          > correctly.[/color]

          .... of course only when JavaScript is not activated in Mozilla Mail. :-)

          Peter.

          Comment

          • kaeli

            #6
            Where does it say that returning false cancels the action of an event handler? (was Re: onreset and Mozilla)

            In article <408EA833.80608 02@spammotel.co m>, LLCSVDYARTMJ@sp ammotel.com
            enlightened us with...[color=blue][color=green]
            > >
            > > Because you cancelled the reset by returning false.
            > > Try onreset="alert( 'hi!')" and watch if it goes.[/color]
            >
            > Well, but this is compliant to the spec. The alert window is shown when
            > the form is reset. In my case, it is not reset since I return false. But
            > why? Where does it say that returning false cancels the action of an
            > event handler?[/color]

            Um, standards? I don't know.

            It's always done that, AFAIK.
            Like when you submit a form and have a handler, like
            <form onSubmit="retur n validate(this)" >
            and the validate returns false, the form doesn't submit.

            Others on this group could answer this way better than I.
            I just code. Others know the standards way more than I do.

            --
            --
            ~kaeli~
            Kill one man and you are a murderer. Kill millions and you
            are a conqueror. Kill everyone and you are God.



            Comment

            • Grant Wagner

              #7
              Re: onreset and Mozilla

              Peter Adolphs wrote:
              [color=blue]
              > kaeli wrote:[color=green]
              > > In article <408E9D5A.80109 00@spammotel.co m>, LLCSVDYARTMJ@sp ammotel.com
              > > enlightened us with...
              > >[color=darkred]
              > >>The W3C HTML 4.01 recommendation states that "The onreset event occurs
              > >>when a form is reset." Using Mozilla 1.4.1, how come that if I set
              > >>onreset="retu rn false;", the form is not reset at all?[/color]
              > >
              > > Because you cancelled the reset by returning false.
              > > Try onreset="alert( 'hi!')" and watch if it goes.[/color]
              >
              > Well, but this is compliant to the spec. The alert window is shown when
              > the form is reset. In my case, it is not reset since I return false. But
              > why? Where does it say that returning false cancels the action of an
              > event handler? That would mean that an event handler can undo an event
              > which it is supposed to react to. ???
              >
              > Peter.[/color]

              Event handlers can't "undo" anything, but they can prevent the action that
              triggered the event from "bubbling up" and being handled by some other aspect
              of the Web browser or operating system. Examples of this are:

              <input type="text" onkeypress="ret urn false;">
              <a href="http://www.yahoo.com" onclick="return false;">
              <form onsubmit="retur n false;">

              Obviously you wouldn't just "return false;" from these events, so something
              more useful is:

              <script type="text/javascript">
              function positiveIntInpu tOnly(e) {
              var k;
              if (e && e.which) { // NS
              k = e.which;
              } else if (window.event && window.event.ke yCode) { // IE
              k = window.event.ke yCode;
              }
              return (!k || ((k > 47 && k < 58) || k == 8));
              }
              </script>
              <input type="text" onkeypress="ret urn positiveIntInpu tOnly(event);">

              <a href="http://www.yahoo.com" onclick="window .open(this.href );return
              false;"> <!-- note this is really a bad idea, but I couldn't think of a
              better example, well I can, but it involves changing <tbody> display style
              attributes vs. reloading the page to display the rows inside the <tbody> for
              fall-back to browsers that can't dynamically change the display style
              attribute -->

              <script type="text/javascript">
              function validate(f) {
              if (f.someInput && f.someInput == 'some value') {
              return true;
              } else {
              return false;
              }
              }
              </script>
              <form onsubmit="retur n validate(this); ">


              --
              | Grant Wagner <gwagner@agrico reunited.com>

              * Client-side Javascript and Netscape 4 DOM Reference available at:
              *


              * Internet Explorer DOM Reference available at:
              *
              Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


              * Netscape 6/7 DOM Reference available at:
              * http://www.mozilla.org/docs/dom/domref/
              * Tips for upgrading JavaScript for Netscape 7 / Mozilla
              * http://www.mozilla.org/docs/web-deve...upgrade_2.html


              Comment

              • Michael Winter

                #8
                Re: onreset and Mozilla

                On Thu, 29 Apr 2004 20:52:04 GMT, Grant Wagner
                <gwagner@agrico reunited.com> wrote:

                [snip]
                [color=blue]
                > Event handlers can't "undo" anything, but they can prevent the action
                > that triggered the event from "bubbling up" and being handled by some
                > other aspect of the Web browser or operating system.[/color]

                Bubbling and cancelling are two completely different things, and you
                appear to have confused them.

                Assuming event propagation isn't interrupted, a dispatched event will flow
                from the document root in a pre-determined route towards the target
                element, firing any capturing listeners as it goes[1]. Once it reaches the
                target, it fires all of the listeners there (except capturing listeners),
                and then bubbles back up the document tree the way it came. Once the event
                reaches the document root again and has finished firing all listeners, the
                browser then, and only then, performs the default action for that event
                type (if one exists).

                If, at any point, a listener returns false (in the old model), calls
                preventDefault( ) (in the DOM model) or sets returnValue to false (in the
                IE model), the event continues as I previously described except that the
                default action is not executed. No change to the event flow occurs.

                Under the IE and DOM event models, you can stop propagation during any of
                the three phases: capture, at target, or bubbling. You do this in IE by
                setting the cancelBubble property of the event to true, or by calling
                stopPropagation () method of the event. All listeners on the current
                element fire, but the event will not proceed to the next element. If the
                event hasn't been cancelled, the default action will then occur.

                [snip]
                [color=blue]
                > function validate(f) {
                > if (f.someInput && f.someInput == 'some value') {
                > return true;
                > } else {
                > return false;
                > }
                > }[/color]

                Wouldn't it be better to write...

                return( f.someInput && ( f.someInput == 'some value' ));

                ....?

                [snip]

                Mike

                [1] It should be noted that IE doesn't support event capture, so this
                phase is skipped.

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

                Comment

                Working...