Results 1 to 4 of 4

Thread: return false does not work in firefox?

  1. #1
    Join Date
    Jan 2009
    Posts
    82
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default return false does not work in firefox?

    I have simple javascript as such to confirm an onClick event before processing:

    Firefox processes whether you click OK or CANCEL??


    <script LANGUAGE="JavaScript">
    <!--
    function confirmSubmit()
    {
    var agree=confirm("Are you sure you want to delete?");
    if (agree)
    return true ;
    else
    return false ;
    }
    // -->
    </script>

    <a href="page.htm" title="delete" onClick="return confirmSubmit()">

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The way that code should work (given no other scripts that would conflict or otherwise affect the outcome) in any browser is, if someone confirms, then page.htm will be loaded into the current base window (usually the current window). If they do not confirm, no change in the current page should occur.

    But, there is no real link in your code:

    Code:
    <a href="page.htm" title="delete" onClick="return confirmSubmit()">
    With only that, there is no closing </a> tag and no text or image to click on to activate it.

    If you do:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head>
    <body>
    <script LANGUAGE="JavaScript">
    <!--
    function confirmSubmit()
    {
    var agree=confirm("Are you sure you want to delete?");
    if (agree)
    return true ;
    else
    return false ;
    }
    // -->
    </script>
    
    <a href="page.htm" title="delete" onClick="return confirmSubmit()">Huh</a>
    </body>
    </html>
    Then it works just as I predicted in FF.

    What exactly is happening?

    Please post a link to the page on your site that contains the problematic code so we can check it out.


    Note: The language attribute for the script tag is deprecated, and the type attribute is required.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    hi, monaya, i suggest you to use firefox and install firebug addon... so if your script error, you will get "why your script is error.."

    OK ?
    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

  4. #4
    Join Date
    Jan 2009
    Posts
    82
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Hmm yes that does work. Thank you!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •