www.webdeveloper.com
Results 1 to 2 of 2

Thread: window.onbeforeunload

  1. #1
    Join Date
    Jul 2009
    Posts
    4

    window.onbeforeunload

    Hello,
    I am using window.onbeforeunload to display a message when the user hits the browser back button. Is there some function to detect the Ok & Cancel button? When the user clicks on the OK button I want it to be redirected to the home page, currently when I click on the back button & click OK in the message box it takes me to the previous page visited.
    Please help,
    Ira

  2. #2
    Join Date
    Aug 2010
    Location
    Baltimore, Maryland, United States
    Posts
    138
    Code:
    function Confirm()
    {
    var x = confirm("Hello");
    if (x == true)
      {
      window.href = "url here";
      }
    else
      {
      alert("You pressed Cancel!");
      }
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles