Browser Bug: 'Object does not support property' error when setting form action (IE6)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    Browser Bug: 'Object does not support property' error when setting form action (IE6)

    Problem
    When setting the FORM object's action property an "Object does not support this property or method" error occurs

    Browser
    Internet Explorer 6-

    Example
    The Javascript code:
    [CODE=javascript]var theForm = document.getEle mentById("formI D");
    theForm.action = "actionpage.php ";
    theForm.submit( );[/CODE]
    Some relevant HTML:[HTML]<input name="action" type="submit" ...>[/HTML]
    Solution
    This is caused by using the name "action" for the submit button which causes IE to be confused between the submit button object and the form's action property. The solution is to rename the submit button (or whatever button or element you have named with a form property).

    It's a bad habit to use reserved words for naming objects anyway.

    More Bugs, Quirks and Inconsistencies
Working...