I cannot get Firefox to execute this code:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mary Ann Gatto
    New Member
    • Jul 2010
    • 3

    I cannot get Firefox to execute this code:

    Code:
    <script language="JavaScript">
    <!--
    
     
    function enterCheck(b){
    	if(b=="PASSWORD")
    		{
    			window.open("http://hhrlifestyle.org/hello.htm")
    			
    		}
    				else alert("The password is not correct.");
    	}
     
    //-->
    
    
    
    </script>
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    how do you call the function?

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      as far as I know, the second parameter in window.open() (the new window’s name) cannot be omitted.

      Comment

      • Mary Ann Gatto
        New Member
        • Jul 2010
        • 3

        #4
        Originally posted by gits
        how do you call the function?
        Code:
        <input type=password name=code1 size=15>
        <input type=button  value="ENTER" onClick="enterCheck(code1.value)"></p>
        It works fine in Internet Explorer, not in Firefox.
        Last edited by gits; Jul 13 '10, 05:46 PM. Reason: added code tags

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          Code:
          enterCheck(code1.value)
          is wrong ... you might use the following, which retrieves the node and its value correctly:

          Code:
          <input type="password" name="code1" id="foo" size=15>
          <input type="button" value="ENTER" onclick="enterCheck(document.getElementById('foo').value)">
          basically you should even enclose attribute values in double quotes.

          Comment

          • Mary Ann Gatto
            New Member
            • Jul 2010
            • 3

            #6
            THANK YOU! PROBLEM SOLVED! Looks like I better brush up on my JavaScript calls.

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5390

              #7
              the problem comes from developing in IE first - which often leads to non standards-compliant scripts that will be broken in all other browsers. it is much more to prefer to develop with FF or Chromium/Chrome - and then fix the much more less IE issues that should occur in the end. the other way round it is often required to fix a lot for standards-compliant browsers ...

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                From what I gather, this script is probably an exercise/tutorial. However, if and when you develop for real, don't use JavaScript to test for passwords. Anyone can quite easily check the source code.

                Comment

                Working...