How to setup javascript redirect to send user to back page? see code

with onclick="history.go(-1);return false;" user can navigate to back pages. but if I want to put a confirm method before it takes user to the back.. how would I do that?

I think it can be achieved by doing something like below but I am not sure how to redirect user to back page?

$('.clickme').click(function() {
    if(confirm("Are you sure you want to navigate away from this page?"))
    {
      //window.close();
      // how to redirect to history.go(-1) ??
    }        
    return false;
 });

Any ideas?

Thank you.

UPDATE

Also is there any way I can check if history has some values in it or is empty?? so that I can alert user if is empty??

How to setup javascript redirect to send user to back page? see code