on leave page ask to go somewhere else

Discussion in 'JavaScript' started by darkmunk, Jul 18, 2007.

  1. #1
    I am using this code to alert the user of an admin page that there is one more thing to do, 'does he want to go to that page now?' confirm/cancel.
    
    function CheckLeave(){
    	if(window.event) {
    		window.event.returnValue = "Would you like to mark this vehicle as sold?";
    		parent.location="admin2.asp?linkID=<%=thisID%>";
    	}
    }
    Code (markup):
    in the body tag I have:
    on onbeforeunload="CheckLeave()"
    Code (markup):
    which is fine for this purpose.

    My problem is am not sure how to do one thing if he confirms and another if he cancels. ??
     
    darkmunk, Jul 18, 2007 IP