How to have window message stay and not leave the page until user clicks button?
===

I need to create dojo button with window that pops up when user tries to leave the page.

    dojo.addOnUnload(window, "test");
    function test() {
      if(hasPendingChange){
        //function goes here i believe
      }
    }

I am pretty sure this is the correct format but, it is leaving the page instead of waiting for user's response. Any ideas?

Thank you!