IE issue with setting action

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • leenadiwan
    New Member
    • Jan 2007
    • 22

    IE issue with setting action

    Hello Friends,

    I have the following code in my JS file:


    Code:
        document.getElementById('form1').action = theContextRoot+myURL;
     
        childWin = window.open("", "myWindow", 'toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,width=450,height=200');
     
        document.getElementById('form1').target = "childWin";
        document.getElementById('form1').submit();

    It is working properly in Mozilla. But in IE I am getting a Javascript error at line 1 while setting action. It says 'Object doesn't support this property or method'

    Why is it so? Any clues/direction? any hints for debugging?

    Thanks a lot in advance!

    Regards,
    Leena
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The action attribute is supported by IE. See this page (action second property).

    Perhaps you could post your form code.

    Comment

    • leenadiwan
      New Member
      • Jan 2007
      • 22

      #3
      Yes I know that IE supports this. I had seen the W3C site page you referred to.

      While I am removing some sensitive information from the html page code to post it here, why do you think the form code will make a difference?
      Any pointers I can myself check and test? Like use of some tags or nesting related issues etc you are aware of that will cause such a problem?

      Regards,
      Leena

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        It is difficult to pinpoint an error without seeing the full code.

        One possibility is that the id might not be "form1", but then it shouldn't work in Firefox either.

        How have you set theContextRoot?

        Comment

        • leenadiwan
          New Member
          • Jan 2007
          • 22

          #5
          In the JSP page from which this JS function is called I have declared it as follows:
          Code:
          <script language=JavaScript>
          var theContextRoot = "<%=request.getContextPath()%>";
          </script>
          The JS function is in a JS file which is included in the JSP page.

          When I print its values, Im getting it right in the JS function.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Ok, I've searched on this, and I discovered this thread. Maybe you have set a form hidden value as "action"?

            Comment

            • leenadiwan
              New Member
              • Jan 2007
              • 22

              #7
              Yes I do have.. I commented the hidden field and tried it again.
              It worked. I did not get the error.

              Why is this so? Im not using it like document.form1. action like in the example.

              Im using it like -
              document.getEle mentById('form1 ').action

              Actually I cannot do without this hidden field on the form.

              Regards,
              Leena

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by leenadiwan
                Yes I do have.. I commented the hidden field and tried it again.
                It worked. I did not get the error.

                Why is this so? Im not using it like document.form1. action like in the example.

                Im using it like -
                document.getEle mentById('form1 ').action

                Actually I cannot do without this hidden field on the form.

                Regards,
                Leena
                You might have to change its name then. It was not a good choice for a variable name too.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by leenadiwan
                  Yes I do have.. I commented the hidden field and tried it again.
                  It worked. I did not get the error.

                  Why is this so? Im not using it like document.form1. action like in the example.

                  Im using it like -
                  document.getEle mentById('form1 ').action

                  Actually I cannot do without this hidden field on the form.

                  Regards,
                  Leena
                  IE is easily confused! Just because you named a form item name "action", it gives precedence to that for some reason and tries to set that to the action value (or some other nonsense)!

                  In any case, action is a bad name to choose for any variable on a page. As r0 mentioned, just change the name to something else and change your server-side script accordingly.

                  Comment

                  Working...