views:

100

answers:

2

When the user goes history-back-1...how do I detect that? And then, alert "the user clicked back!"

Using binds (and jquery preferably)

+4  A: 

You can't (browser security restriction). You can tell if the user navigates away from the page (onbeforeunload, onunload fire) but you can't tell where they went.

EricLaw -MSFT-
+1  A: 

try:

window.onbeforeunload = function (evt) {
  var message = 'Are you sure you want to leave?';
  if (typeof evt == 'undefined') {
    evt = window.event;
  }
  if (evt) {
    evt.returnValue = message;
  }
  return message;
}
Adnan