Javascript fails in Firefox (OK in IE)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ajr121@googlemail.com

    Javascript fails in Firefox (OK in IE)

    The following cgi generated html page has the following Javascript in
    the Body section:-

    <script language="JavaS cript" type="text/javascript">
    <!-- Begin
    function eHistorical()
    {
    document.F1.act ion="http://www.somedomain/historicalitems .htm";
    F1.submit();
    }

    //-->
    </script>

    Further down the page we have the following Form :-

    <form name="F1">
    <p align="right">
    <input type = "button" name="B2" value = "Historical Items" onclick
    ="eHistorical() ">
    </p>
    </form>

    The page loads OK but when button B2 it clicked the following error is
    reported by Firefox :-

    "F1 is not defined"

    Any thoughts - it works fine in IE.



  • Stevo

    #2
    Re: Javascript fails in Firefox (OK in IE)

    ajr121@googlema il.com wrote:
    document.F1.act ion="http://www.somedomain/historicalitems .htm";
    >
    Further down the page we have the following Form :-
    >
    <form name="F1">
    >
    The page loads OK but when button B2 it clicked the following error is
    reported by Firefox :-
    >
    "F1 is not defined"
    >
    Any thoughts - it works fine in IE.
    It's IE that's incorrectly allowing you to take that shortcut of
    addressing it as document.F1. Ideally you should be using
    document.forms. F1 instead.

    Comment

    • SAM

      #3
      Re: Javascript fails in Firefox (OK in IE)

      ajr121@googlema il.com a écrit :
      The following cgi generated html page has the following Javascript in
      the Body section:-
      >
      <script language="JavaS cript" type="text/javascript">
      <!-- Begin
      function eHistorical()
      {
      document.F1.act ion="http://www.somedomain/historicalitems .htm";
      F1.submit();
      }
      >
      //-->
      </script>
      <script type="text/javascript">

      function eHistorical()
      {
      document.F1.act ion="http://www.somedomain/historicalitems .htm";
      document.F1.sub mit();
      }
      </script>

      --
      sm

      Comment

      • Richard Cornford

        #4
        Re: Javascript fails in Firefox (OK in IE)

        ajr121@googlema il.com wrote:
        The following cgi generated html page has the following
        Javascript in the Body section:-
        >
        <script language="JavaS cript" type="text/javascript">
        <!-- Begin
        function eHistorical()
        {
        document.F1.act ion="http://www.somedomain/historicalitems .htm";
        F1.submit();
        }
        >
        //-->
        </script>
        >
        Further down the page we have the following Form :-
        >
        <form name="F1">
        <p align="right">
        <input type = "button" name="B2" value = "Historical Items"
        onclick ="eHistorical() ">
        </p>
        </form>
        >
        The page loads OK but when button B2 it clicked the
        following error is
        reported by Firefox :-
        >
        "F1 is not defined"
        >
        Any thoughts - it works fine in IE.
        Factors that could influence this behaviour would be outside of the code
        you have posted. If you want an answer we will need to see the context.

        However, don't do that. There is no need to involve javascript in this
        at all, and if you don't you will certainly not get any javascript
        issues. Consider:-

        <form action="http://www.somedomain/historicalitems .htm">
        <p align="right">
        <input type="submit" name="B2" value="Historic al Items">
        </p>
        </form>

        - without any scripting at all.

        Richard.

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          [OT] Using forms form links (was: Javascript fails in Firefox (OKin IE))

          Richard Cornford wrote:
          ajr121@googlema il.com wrote:
          >The following cgi generated html page has the following
          >Javascript in the Body section:-
          >>
          ><script language="JavaS cript" type="text/javascript">
          ><!-- Begin
          >function eHistorical()
          >{
          >document.F1.ac tion="http://www.somedomain/historicalitems .htm";
          >F1.submit();
          >}
          >>
          >//-->
          ></script>
          >>
          >Further down the page we have the following Form :-
          >>
          ><form name="F1">
          JFTR: The `action' attribute is #REQUIRED, and missing here.
          ><p align="right">
          ><input type = "button" name="B2" value = "Historical Items"
          >onclick ="eHistorical() ">
          ></p>
          ></form>
          >>
          >The page loads OK but when button B2 it clicked the
          >following error is
          >reported by Firefox :-
          >[...]
          >
          [...] There is no need to involve javascript in this
          at all, and if you don't you will certainly not get any javascript
          issues. Consider:-
          >
          <form action="http://www.somedomain/historicalitems .htm">
          <p align="right">
          <input type="submit" name="B2" value="Historic al Items">
          </p>
          </form>
          To satisfy the requirements of HTML 4.01 Strict (else you would not need any
          of it), one should use DIV instead of P here, for there is no running text
          inside a paragraph. Also, CSS text-align:right MUST then be used instead of
          the deprecated `align' attribute; with HTML 4.01 Transitional, it only
          SHOULD be used.

          Another variant, IMHO the better one, is not to use a form in the first
          place, and to use a styled hyperlink instead. That way the user could also
          be informed about the visit status of the target resource in an accessible way.
          - without any scripting at all.
          Full ACK.


          PointedEars
          --
          var bugRiddenCrashP ronePieceOfJunk = (
          navigator.userA gent.indexOf('M SIE 5') != -1
          && navigator.userA gent.indexOf('M ac') != -1
          ) // Plone, register_functi on.js:16

          Comment

          Working...