Javascript firefox problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Blair

    Javascript firefox problem

    Hi,
    I have a problem with our intranet, we are planning to install Firefox
    instead of Internet Explorer onto some new PCs.

    However, we can't get the following JavaScript to work in Firefox and
    similar code is used in lots of the intranet stuff.
    The code should bring up a message box with a warning and not allow
    the user to continue unless they have filled in the entry in an html
    form (the form is called 'myauthor').


    if (checkempty(Doc ument.myauthor. Candidate.Value ,"You have left the
    Candidate field empty."))= false then validation=fals e


    If validation= True then
    myauthor_OnSubm it = True
    else
    myauthor_OnSubm it = False
    End if
    End function


    Function checkempty(ByVa l FieldValue, ByVal message)
    If FieldValue = "" then
    MsgBox message, 8, Header
    checkempty = False
    else
    checkempty = true
    End if
    end function

    No errors or warnings appear in the firefox JavaScript console. The
    page just accepts the form and continues as if the checking code
    weren't there at all.

    Thanks for any help,
    Dave

  • Martin Honnen

    #2
    Re: Javascript firefox problem



    Dave Blair wrote:

    [color=blue]
    > However, we can't get the following JavaScript to work in Firefox and
    > similar code is used in lots of the intranet stuff.
    > The code should bring up a message box with a warning and not allow[/color]

    [color=blue]
    > if (checkempty(Doc ument.myauthor. Candidate.Value ,"You have left the
    > Candidate field empty."))= false then validation=fals e
    >
    >
    > If validation= True then
    > myauthor_OnSubm it = True
    > else
    > myauthor_OnSubm it = False
    > End if
    > End function
    >
    >
    > Function checkempty(ByVa l FieldValue, ByVal message)
    > If FieldValue = "" then
    > MsgBox message, 8, Header
    > checkempty = False
    > else
    > checkempty = true
    > End if
    > end function
    >
    > No errors or warnings appear in the firefox JavaScript console. The
    > page just accepts the form and continues as if the checking code
    > weren't there at all.[/color]

    That is not JavaScript but VBScript so there is no way FireFox or any
    other browser besides IE/Win is going to run that code.

    --

    Martin Honnen


    Comment

    • Søren Munk Skrøder

      #3
      Re: Javascript firefox problem

      Dave Blair wrote:
      [color=blue]
      > Hi,
      > I have a problem with our intranet, we are planning to install Firefox
      > instead of Internet Explorer onto some new PCs.
      >
      > However, we can't get the following JavaScript to work in Firefox and
      > similar code is used in lots of the intranet stuff.
      > The code should bring up a message box with a warning and not allow
      > the user to continue unless they have filled in the entry in an html
      > form (the form is called 'myauthor').
      >
      >
      > if (checkempty(Doc ument.myauthor. Candidate.Value ,"You have left the
      > Candidate field empty."))= false then validation=fals e
      >
      >
      > If validation= True then
      > myauthor_OnSubm it = True
      > else
      > myauthor_OnSubm it = False
      > End if
      > End function
      >
      >
      > Function checkempty(ByVa l FieldValue, ByVal message)
      > If FieldValue = "" then
      > MsgBox message, 8, Header
      > checkempty = False
      > else
      > checkempty = true
      > End if
      > end function
      >
      > No errors or warnings appear in the firefox JavaScript console. The
      > page just accepts the form and continues as if the checking code
      > weren't there at all.
      >
      > Thanks for any help,
      > Dave
      >[/color]

      Hmm ... perhaps it's because most of the code, you've written isn't
      Javascript - but rather VBScript which is also supported in IE

      i've taken the liberty to rewrite it (sort of) in javascript...

      function checkEmpty( value, errMessage ) {
      if(value=="") {
      Alert( errMessage );
      return false;
      } else {
      return true;
      }
      }


      if( checkEmpty( document.forms['myauthor'].candidate.valu e, "You have
      left the Candidate field empty..." ) ) {
      /* validation ok - submit the form */
      document.forms['myauthor'].submit();
      } else {
      /* don't do anything - vaidation failed */
      return false;
      }

      /Søren Munk Skrøder
      Odense, Denmark
      soeren at skroeder dot dk

      Comment

      • Dave Blair

        #4
        Re: Javascript firefox problem

        I'm an idiot!!

        I knew it was VBscript, but had just finished with another problem
        that was Javascript (a menu, which is now working). And somehow my
        brain hadn't woken up and...........m onday morning.....and ......

        Anyway, thanks for the replies and the re-write!

        On Mon, 28 Jun 2004 14:45:06 +0200,
        =?ISO-8859-1?Q?S=F8ren_Mun k_Skr=F8der?= <a@b.com> wrote:
        [color=blue]
        >Dave Blair wrote:
        >[color=green]
        >> Hi,
        >> I have a problem with our intranet, we are planning to install Firefox
        >> instead of Internet Explorer onto some new PCs.
        >>
        >> However, we can't get the following JavaScript to work in Firefox and
        >> similar code is used in lots of the intranet stuff.
        >> The code should bring up a message box with a warning and not allow
        >> the user to continue unless they have filled in the entry in an html
        >> form (the form is called 'myauthor').
        >>
        >>
        >> if (checkempty(Doc ument.myauthor. Candidate.Value ,"You have left the
        >> Candidate field empty."))= false then validation=fals e
        >>
        >>
        >> If validation= True then
        >> myauthor_OnSubm it = True
        >> else
        >> myauthor_OnSubm it = False
        >> End if
        >> End function
        >>
        >>
        >> Function checkempty(ByVa l FieldValue, ByVal message)
        >> If FieldValue = "" then
        >> MsgBox message, 8, Header
        >> checkempty = False
        >> else
        >> checkempty = true
        >> End if
        >> end function
        >>
        >> No errors or warnings appear in the firefox JavaScript console. The
        >> page just accepts the form and continues as if the checking code
        >> weren't there at all.
        >>
        >> Thanks for any help,
        >> Dave
        >>[/color]
        >
        >Hmm ... perhaps it's because most of the code, you've written isn't
        >Javascript - but rather VBScript which is also supported in IE
        >
        >i've taken the liberty to rewrite it (sort of) in javascript...
        >
        >function checkEmpty( value, errMessage ) {
        > if(value=="") {
        > Alert( errMessage );
        > return false;
        > } else {
        > return true;
        > }
        >}
        >
        >
        >if( checkEmpty( document.forms['myauthor'].candidate.valu e, "You have
        >left the Candidate field empty..." ) ) {
        > /* validation ok - submit the form */
        > document.forms['myauthor'].submit();
        >} else {
        > /* don't do anything - vaidation failed */
        > return false;
        >}
        >
        >/Søren Munk Skrøder
        >Odense, Denmark
        >soeren at skroeder dot dk[/color]

        Comment

        • Mark Preston

          #5
          Re: Javascript firefox problem

          Dave Blair wrote:
          [color=blue]
          > Hi,
          > I have a problem with our intranet, we are planning to install Firefox
          > instead of Internet Explorer onto some new PCs.
          >
          > However, we can't get the following JavaScript to work in Firefox and
          > similar code is used in lots of the intranet stuff.[/color]
          [snip][color=blue]
          >
          > Function checkempty(ByVa l FieldValue, ByVal message)
          > If FieldValue = "" then
          > MsgBox message, 8, Header
          > checkempty = False
          > else
          > checkempty = true
          > End if
          > end function
          >[/color]
          That code (above) is VBScript, not JavaScript or ECMAScript, so it has
          no chance on anything except Microsoft-only browsers written to work
          with Micrososft-only code. In other words - it will never run on Firefox
          OR on any non-Wondows system.

          Comment

          Working...