Results 1 to 2 of 2

Thread: confirm redirects but alert doesnt

  1. #1
    Join Date
    Jun 2008
    Posts
    121
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default confirm redirects but alert doesnt

    hi all

    i am calling one function after another.

    The below code shows a confirmation box and redirects to yahoo.com
    Code:
    <script type="text/javascript">
    function todo(){
    window.location="http://www.yahoo.com";
    }
    function conf(){
    if(confirm("do you want to exit"))
    {
    todo();
    }
    }
    </script>

    Now instead of confirmation box if i show an alert box then the redirect doesnt works. why.

    Code:
    <script type="text/javascript">
    function todo(){
    window.location="http://www.yahoo.com";
    }
    function conf(){
    if(alert("you are now going to exit"))
    {
    todo();
    }
    }
    vineet

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    alert returns undefined (i.e. nothing) and undefined == false.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

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
  •