JavaScript error with onChange event handler -- FireFox 1.5

Discussion in 'Javascript' started by David McNerney, Apr 5, 2006.

  1. Would anyone be able to tell me why I get an error in FireFox 1.5.0.1
    for MacOSX when I type some text and hit Enter in the following form:

    <html>
    <body>
    <form action="http://example.com" onSubmit="return false;">
    <input type="text" name="samplenum" value=""
    onChange="alert('onChange fired');">
    <input type="submit" name="cmd_submit" value="Submit"
    onClick="return false">
    </form>
    </body>
    </html>

    Needless to say, this is a pruned down toy example. It seems like there
    must be a bug, but I'd like to make sure that I'm not doing something
    wrong. I don't get the error if I remove the onChange event handler.
    The error reads:

    Error: [Exception... "'Permission denied to set property
    XULElement.selectedIndex' when calling method:
    [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e
    (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
    file:///Users/dave/sy_dir/u01/app/lims/httpd/htdocs/ajax.html ::
    onchange :: line 1" data: no]
    Source File:
    file:///Users/dave/sy_dir/u01/app/lims/httpd/htdocs/ajax.html
    Line: 1
     
    David McNerney, Apr 5, 2006
    #1
    1. Advertising

  2. David McNerney

    Zif Guest

    David McNerney said on 05/04/2006 11:38 AM AEST:
    > Would anyone be able to tell me why I get an error in FireFox 1.5.0.1
    > for MacOSX when I type some text and hit Enter in the following form:
    >
    > <html>
    > <body>
    > <form action="http://example.com" onSubmit="return false;">
    > <input type="text" name="samplenum" value=""
    > onChange="alert('onChange fired');">
    > <input type="submit" name="cmd_submit" value="Submit"
    > onClick="return false">
    > </form>
    > </body>
    > </html>
    >
    > Needless to say, this is a pruned down toy example. It seems like there
    > must be a bug, but I'd like to make sure that I'm not doing something
    > wrong. I don't get the error if I remove the onChange event handler.
    > The error reads:
    >
    > Error: [Exception... "'Permission denied to set property
    > XULElement.selectedIndex' when calling method:
    > [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e
    > (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
    > file:///Users/dave/sy_dir/u01/app/lims/httpd/htdocs/ajax.html ::
    > onchange :: line 1" data: no]
    > Source File:
    > file:///Users/dave/sy_dir/u01/app/lims/httpd/htdocs/ajax.html
    > Line: 1


    You'll be pleased to know that the same thing happens in Firefox on
    Windows. It's related to the 'onclick' attribute you've put on the
    submit button - get rid of that and the error goes away.

    It may still be worth logging a bug since it doesn't happen if you click
    the submit button or don't fire the onchange simultaneously (e.g. cause
    the onchange to fire first by tabbing or blurring the control, then do a
    submit).

    Other than the error message, does your form scripting malfunction as a
    result?


    --
    Zif
     
    Zif, Apr 5, 2006
    #2
    1. Advertising

  3. David McNerney

    VK Guest

    David McNerney wrote:
    > Would anyone be able to tell me why I get an error in FireFox 1.5.0.1
    > for MacOSX when I type some text and hit Enter in the following form:
    >
    > <html>
    > <body>
    > <form action="http://example.com" onSubmit="return false;">
    > <input type="text" name="samplenum" value=""
    > onChange="alert('onChange fired');">
    > <input type="submit" name="cmd_submit" value="Submit"
    > onClick="return false">
    > </form>
    > </body>
    > </html>
    >
    > Needless to say, this is a pruned down toy example. It seems like there
    > must be a bug, but I'd like to make sure that I'm not doing something
    > wrong. I don't get the error if I remove the onChange event handler.
    > The error reads:
    >
    > Error: [Exception... "'Permission denied to set property
    > XULElement.selectedIndex' when calling method:
    > [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e
    > (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
    > file:///Users/dave/sy_dir/u01/app/lims/httpd/htdocs/ajax.html ::
    > onchange :: line 1" data: no]
    > Source File:
    > file:///Users/dave/sy_dir/u01/app/lims/httpd/htdocs/ajax.html
    > Line: 1


    That looks like the old autocomplete bug, but it was fixed in Firefox
    1.5. Are you sure that your version is 1.5 and not say 1.0.7? If indeed
    then somehow it was preserved in the MacOS build. Under Windows (98 and
    XP) it was fixed for sure - I don't know why other respondent says it
    was not. You code runs w/o exceptions on test machines.

    The fix is to use autocomplete="off"

    <input type="text" name="samplenum" value=""
    autocomplete="off"
    onChange="alert('onChange fired');">

    Of course it is not an option if you *need* to have autocomplete on.
    Also this bug leads to an exception, not to an error: it means that
    script execution is not aborted. But numerous exceptions may lead to an
    execution slow-down (plus JavaScript console gets "pollued")
     
    VK, Apr 5, 2006
    #3
  4. David McNerney

    Zif Guest

    VK said on 05/04/2006 6:25 PM AEST:
    [...]
    > That looks like the old autocomplete bug, but it was fixed in Firefox
    > 1.5. Are you sure that your version is 1.5 and not say 1.0.7? If indeed
    > then somehow it was preserved in the MacOS build. Under Windows (98 and
    > XP) it was fixed for sure - I don't know why other respondent says it
    > was not.


    Because, when tested, it behaved exactly the same for Firefox 1.5.0.1 on
    Windows XP as the OP described for Mac OS X. Re-testing today shows it
    hasn't changed.

    I don't presume to guess why.


    > You code runs w/o exceptions on test machines.


    That was not the result here.


    > The fix is to use autocomplete="off"


    Yes, that 'fixes' it.

    [...]



    --
    Zif
     
    Zif, Apr 6, 2006
    #4
  5. Thank everyone for the information! My script didn't malfunction, but
    the error caused me some confusion in debugging an unrelated browser
    hang. Definitely FF 1.5 BTW.
     
    David McNerney, Apr 7, 2006
    #5
    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. Replies:
    1
    Views:
    756
    Damien
    Feb 22, 2007
  2. Lewis Holmes
    Replies:
    5
    Views:
    2,837
    Allen Chen [MSFT]
    Mar 18, 2009
  3. Bill
    Replies:
    1
    Views:
    176
    Thomas 'PointedEars' Lahn
    Oct 23, 2003
  4. Replies:
    0
    Views:
    122
  5. yawnmoth

    onchange event handler and select tags

    yawnmoth, Dec 11, 2007, in forum: Javascript
    Replies:
    5
    Views:
    204
    Thomas 'PointedEars' Lahn
    Dec 12, 2007
Loading...

Share This Page