I need to through alert message like "Are you want to navigate?" when user will modify some data but did not save that and trying to navigate to the other tab. 

I want yes or No functionality on clicking on other tab. Not leave this page or stay on this.

Kinldy help me. Thanks In advanced. 

```js
function goodbye(e) {
  if (!e) e = window.event;
  //e.cancelBubble is supported by IE - this will kill the bubbling process.
  e.cancelBubble = true;
  e.returnValue = 'You sure you want to leave?'; //This is displayed on the dialog

  //e.stopPropagation works in Firefox.
  if (e.stopPropagation) {
    e.stopPropagation();
    e.preventDefault();
  }
}
window.onbeforeunload = goodbye;

```

I have used this but it is not showing yes/no.and in same page some buttons are there. After clicking this page is refreshing and this message is coming. can some one plz help me.