page is navigating if i clicks Cancel button.

page is navigating if i clicks Cancel button.

 

jQuery(window).unload(

function () {

var yes= confirm( "You are about to leave this page.Please make sure you have saved your changes." );
if (yes) {
return true;

}
else {

return false;

}

});
 
Hi Sir,
 
i am trying to populate this message if user is trying to navigate to other screen.
but if i clicks cancel still it is navigating to other page.
 
Please help me what i should do to stop the user to navigate to other page.
 
Thanks in advance
Amit